From 5fe289be316edeb1379a7216f2344345b05546ad Mon Sep 17 00:00:00 2001 From: Dmitry Tyshchenko Date: Thu, 4 Jun 2020 14:50:08 +0300 Subject: [PATCH] Update nsfw to 2.0.0 --- packages/core-kernel/package.json | 2 +- .../src/services/config/watcher.ts | 33 +++---------------- yarn.lock | 30 +++++++---------- 3 files changed, 17 insertions(+), 48 deletions(-) diff --git a/packages/core-kernel/package.json b/packages/core-kernel/package.json index 05aab66505..76a471ffd6 100644 --- a/packages/core-kernel/package.json +++ b/packages/core-kernel/package.json @@ -34,7 +34,7 @@ "inversify": "^5.0.1", "log-process-errors": "^5.0.3", "nanomatch": "^1.2.13", - "nsfw": "^1.2.5", + "nsfw": "^2.0.0", "reflect-metadata": "^0.1.13", "semver": "^6.3.0", "type-fest": "^0.14.0" diff --git a/packages/core-kernel/src/services/config/watcher.ts b/packages/core-kernel/src/services/config/watcher.ts index 5d8c57eefd..5c955d4492 100644 --- a/packages/core-kernel/src/services/config/watcher.ts +++ b/packages/core-kernel/src/services/config/watcher.ts @@ -1,31 +1,8 @@ -import nsfw from "nsfw"; +import nsfw, { ActionType, NSFW } from "nsfw"; import { Application } from "../../contracts/kernel"; import { Identifiers, inject, injectable } from "../../ioc"; -/** - * @interface FileEvent - */ -interface FileEvent { - /** - * @type {number} - * @memberof FileEvent - */ - action: number; - - /** - * @type {string} - * @memberof FileEvent - */ - directory: string; - - /** - * @type {string} - * @memberof FileEvent - */ - file: string; -} - /** * @export * @class Watcher @@ -44,10 +21,10 @@ export class Watcher { /** * @private - * @type {nsfw} + * @type {NSFW} * @memberof Watcher */ - private watcher: nsfw; + private watcher!: NSFW; /** * @returns {Promise} @@ -56,9 +33,9 @@ export class Watcher { public async boot(): Promise { const configFiles: string[] = [".env", "delegates.json", "peers.json", "plugins.js", "plugins.json"]; - this.watcher = await nsfw(this.app.configPath(), (events: FileEvent[]) => { + this.watcher = await nsfw(this.app.configPath(), (events) => { for (const event of events) { - if (configFiles.includes(event.file) && event.action === nsfw.actions.MODIFIED) { + if (event.action === ActionType.MODIFIED && configFiles.includes(event.file)) { this.app.reboot(); } } diff --git a/yarn.lock b/yarn.lock index dc94a3772d..158942deb0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9496,11 +9496,6 @@ lodash.isfunction@^3.0.8, lodash.isfunction@~3.0.8: resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz#06de25df4db327ac931981d1bdb067e5af68d051" integrity sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw== -lodash.isinteger@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343" - integrity sha1-YZwK89A/iwTDH1iChAt3sRzWg0M= - lodash.ismatch@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" @@ -9511,11 +9506,6 @@ lodash.isnumber@^3.0.3: resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" integrity sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w= -lodash.isundefined@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash.isundefined/-/lodash.isundefined-3.0.1.tgz#23ef3d9535565203a66cefd5b830f848911afb48" - integrity sha1-I+89lTVWUgOmbO/VuDD4SJEa+0g= - lodash.map@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" @@ -10276,7 +10266,7 @@ mz@^2.4.0, mz@^2.5.0, mz@^2.7.0: object-assign "^4.0.1" thenify-all "^1.0.0" -nan@^2.0.0, nan@^2.12.1, nan@^2.13.1, nan@^2.13.2: +nan@^2.12.1, nan@^2.13.1, nan@^2.13.2: version "2.14.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c" integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg== @@ -10395,6 +10385,11 @@ node-abi@^2.7.0: dependencies: semver "^5.4.1" +node-addon-api@*: + version "3.0.0" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.0.0.tgz#812446a1001a54f71663bed188314bba07e09247" + integrity sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg== + node-addon-api@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.0.tgz#f9afb8d777a91525244b01775ea0ddbe1125483b" @@ -10774,15 +10769,12 @@ npm-run-path@^4.0.0: gauge "~2.7.3" set-blocking "~2.0.0" -nsfw@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/nsfw/-/nsfw-1.2.5.tgz#febe581af616f7b042f89df133abe62416c4c803" - integrity sha512-m3mwZUKXiCR69PDMLfAmKmiNzy0Oe9LhFE0DYZC5cc1htNj5Hyb1sAgglXhuaDkibFy22AVvPC5cCFB3A6mYIw== +nsfw@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/nsfw/-/nsfw-2.0.0.tgz#b0e431dbccf7ea01fc31d9285325ad31f0aaf5a8" + integrity sha512-MO/+8Gjqnm8YviA0H4XZccz38wXhFNc4w7UCqsvge/cOyoN8tNzDUF257CyJzEUPmcJB0YRtMt9IKLE1eCOu+A== dependencies: - fs-extra "^7.0.0" - lodash.isinteger "^4.0.4" - lodash.isundefined "^3.0.1" - nan "^2.0.0" + node-addon-api "*" number-is-nan@^1.0.0: version "1.0.1"