rizowski / eslint-watch

ESLint with simple watching capabilities
https://www.npmjs.com/package/eslint-watch
MIT License
196 stars 29 forks source link

exitCode variable in process.on('exit') will cause program to crash on windows #135

Closed RonanQuigley closed 5 years ago

RonanQuigley commented 6 years ago

Environment

Basic Description of the problem

On windows, the following line in your index file causes npm to throw an error in the command line when quitting eslint-watch with ctrl + c:

process.on('exit', function () {
  logger.debug(`Exiting: ${exitCode}`);
  process.exit(exitCode); 
});

The exitCode variable is what is crashing it. By removing it altogether, the issue is gone:

process.on('exit', function () {
  // logger.debug(`Exiting: ${exitCode}`);
  // process.exit(exitCode);
  process.exit(0);
});

How to reproduce it

node node_modules/eslint-watch/bin/esw -w --fix

I haven't tested this issue on Mac, but my OS is windows 10 for replicating it.

I'm aware that Node 8+ isn't tested, but I've made a fork here that fixes the offending file for now:

https://github.com/RonanQuigley/eslint-watch/blob/master/src/index.js

Debug Output

I couldn't get the set option to work for some reason, but it just boils down to the use of a variable on exiting:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'watch:lint' ]
2 info using npm@5.6.0
3 info using node@v9.7.1
4 verbose run-script [ 'prewatch:lint', 'watch:lint', 'postwatch:lint' ]
5 info lifecycle isomorphic-hot-reloading-boilerplate@1.0.0~prewatch:lint: isomorphic-hot-reloading-boilerplate@1.0.0
6 info lifecycle isomorphic-hot-reloading-boilerplate@1.0.0~watch:lint: isomorphic-hot-reloading-boilerplate@1.0.0
7 verbose lifecycle isomorphic-hot-reloading-boilerplate@1.0.0~watch:lint: unsafe-perm in lifecycle true
8 verbose lifecycle isomorphic-hot-reloading-boilerplate@1.0.0~watch:lint: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Ronan\Desktop\hot-reloading-boilerplate-redux\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Ronan\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\Common Files\Adobe\AGL;C:\Program Files (x86)\QuickTime\QTSystem;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Users\Ronan\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Program Files\nodejs;C:\Program Files (x86)\Yarn\bin;C:\Program Files\Git\cmd;C:\Users\Ronan\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\Ronan\AppData\Local\Microsoft\WindowsApps;C:\Users\Ronan\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Users\Ronan\AppData\Roaming\npm;C:\Users\Ronan\AppData\Local\Yarn\bin
9 verbose lifecycle isomorphic-hot-reloading-boilerplate@1.0.0~watch:lint: CWD: C:\Users\Ronan\Desktop\hot-reloading-boilerplate-redux
10 silly lifecycle isomorphic-hot-reloading-boilerplate@1.0.0~watch:lint: Args: [ '/d /s /c',
10 silly lifecycle   'node node_modules/eslint-watch/bin/esw -w --fix --debug' ]
11 silly lifecycle isomorphic-hot-reloading-boilerplate@1.0.0~watch:lint: Returned: code: 1  signal: null
12 info lifecycle isomorphic-hot-reloading-boilerplate@1.0.0~watch:lint: Failed to exec watch:lint script
13 verbose stack Error: isomorphic-hot-reloading-boilerplate@1.0.0 watch:lint: `node node_modules/eslint-watch/bin/esw -w --fix --debug`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack     at EventEmitter.emit (events.js:127:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:127:13)
13 verbose stack     at maybeClose (internal/child_process.js:936:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid isomorphic-hot-reloading-boilerplate@1.0.0
15 verbose cwd C:\Users\Ronan\Desktop\hot-reloading-boilerplate-redux
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch:lint"
18 verbose node v9.7.1
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error isomorphic-hot-reloading-boilerplate@1.0.0 watch:lint: `node node_modules/eslint-watch/bin/esw -w --fix --debug`
22 error Exit status 1
23 error Failed at the isomorphic-hot-reloading-boilerplate@1.0.0 watch:lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
rizowski commented 6 years ago

@RonanQuigley Can you post the eslint-watch debug information by setting the environment variable DEBUG to esw:* and rerunning the command. There must be something else going on here. Commenting out those lines would mean you won't get the right exit code if linting fails. You are also running this on a node version that isn't actively tested on.

RonanQuigley commented 6 years ago

Okay, I used cross-env instead to get it working and the output is as follows:

  esw:esw-cli -w seen +1ms
  esw:watcher { useEslintrc: true,
  esw:watcher   ignore: true,
  esw:watcher   fix: true,
  esw:watcher   format: 'simple-detail' } +2s
  esw:watcher { watch: true,
  esw:watcher   fix: true,
  esw:watcher   format: 'simple-detail',
  esw:watcher   eslintrc: true,
  esw:watcher   ignore: true,
  esw:watcher   inlineConfig: true,
  esw:watcher   _: [] } +0ms
  esw:watcher Trying to load formatter for re-lint from ./formatters/simple-detail +2ms
  esw:simple-detail loaded +0ms
  esw:watcher Watching: [ 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux' ] +30ms
  esw:esw-cli c was pressed +22

Interestingly it doesn't crash with debugging enabled. And yep, I'm aware that this version of node isn't tested, so if it's out of your scope, no worries.

RonanQuigley commented 6 years ago

Actually, scrap what I just said, I just realised I left the fix on whilst running the debug option. This is it with the fix removed:

  esw:internal-settings Eslint installed locally node_modules\.bin\eslint.cmd +0ms
  esw:internal-settings { eslintPath: 'node_modules\\.bin\\eslint.cmd',
  esw:internal-settings   platform: 'win32',
  esw:internal-settings   isWindows: true } +2ms
  esw:eslint-cli Loaded +0ms
  esw:eslint-help Loaded +0ms
  esw:options Loaded +0ms
  esw:eslint-help Executing help +1ms
  esw:eslint-cli eslint: '--help' +31ms
  esw:executor node_modules\.bin\eslint.cmd [ '--help' ] +0ms
  esw:eslint-cli { exitCode: 0,
  esw:eslint-cli   message: 'eslint [options] file.js [file.js] [dir]\n\nBasic configuration:\n  --no-eslintrc                  Disable use of configuration from .eslintrc.*\n  -c, --config path::String      Use this configuration, overriding .eslintrc.* config options if present\n  --env [String]                 Specify environments\n  --ext [String]                 Specify JavaScript file extensions - default: .js\n  --global [String]              Define global variables\n  --parser String                Specify the parser to be used\n  --parser-options Object
   Specify parser options\n\nSpecifying rules and plugins:\n  --rulesdir [path::String]      Use additional rules from this directory\n  --plugin [String]              Specify plugins\n  --rule Object                  Specify rules\n\nFixing problems:\n  --fix                          Automatically fix problems\n  --fix-dry-run                  Automatically fix problems without
saving the changes to the file system\n\nIgnoring files:\n  --ignore-path path::String     Specify path of ignore file\n  --no-ignore                    Disable use of ignore files and patterns\n  --ignore-pattern [String]      Pattern of files to ignore (in addition to those in .eslintignore)\n\nUsing stdin:\n  --stdin                        Lint code provided on <STDIN> - default: false\n  --stdin-filename String        Specify filename to process STDIN as\n\nHandling warnings:\n  --quiet                        Report errors only - default: false\n  --max-warnings
Int             Number of warnings to trigger nonzero exit code - default: -1\n\nOutput:\n  -o, --output-file path::String  Specify file to write report to\n  -f, --format String            Use a specific output format - default: stylish\n  --color, --no-color            Force enabling/disabling of color\n\nInline configuration comments:\n  --no-inline-config             Prevent
comments from changing config or rules\n  --report-unused-disable-directives  Adds reported errors for unused eslint-disable directives\n\nCaching:\n  --cache                        Only check changed files - default: false\n  --cache-file path::String      Path to the cache file. Deprecated: use --cache-location - default: .eslintcache\n  --cache-location path::String  Path to the cache file or directory\n\nMiscellaneous:\n  --init                         Run config initialization wizard - default: false\n  --debug                        Output debugging information\n  -h, --help                     Show help\n  -v, --version                  Output the version number\n  --print-config path::String    Print the configuration for the given file\n' } +541ms
  esw:eslint-help Parsing --no-eslintrc +544ms
  esw:eslint-help Parsing no option --no-eslintrc +0ms
  esw:eslint-help Alias found: -c +1ms
  esw:eslint-help Parsing --config +0ms
  esw:eslint-help Parsing --env +0ms
  esw:eslint-help Parsing --ext +0ms
  esw:eslint-help Parsing --global +0ms
  esw:eslint-help Parsing --parser +1ms
  esw:eslint-help Parsing --parser-options +0ms
  esw:eslint-help Parsing --rulesdir +0ms
  esw:eslint-help Parsing --plugin +0ms
  esw:eslint-help Parsing --rule +1ms
  esw:eslint-help Parsing --fix +0ms
  esw:eslint-help Parsing --fix-dry-run +0ms
  esw:eslint-help Parsing --ignore-path +0ms
  esw:eslint-help Parsing --no-ignore +0ms
  esw:eslint-help Parsing no option --no-ignore +0ms
  esw:eslint-help Parsing --ignore-pattern +1ms
  esw:eslint-help Parsing --stdin +0ms
  esw:eslint-help Parsing --stdin-filename +0ms
  esw:eslint-help Parsing --quiet +0ms
  esw:eslint-help Parsing --max-warnings +0ms
  esw:eslint-help Alias found: -o +1ms
  esw:eslint-help Parsing --output-file +0ms
  esw:eslint-help Alias found: -f +0ms
  esw:eslint-help Parsing --format +0ms
  esw:eslint-help Parsing --no-inline-config +1ms
  esw:eslint-help Parsing no option --no-inline-config +0ms
  esw:eslint-help Parsing --report-unused-disable-directives +0ms
  esw:eslint-help Parsing --cache +0ms
  esw:eslint-help Parsing --cache-file +0ms
  esw:eslint-help Parsing --cache-location +0ms
  esw:eslint-help Parsing --init +1ms
  esw:eslint-help Parsing --debug +0ms
  esw:eslint-help Alias found: -h +0ms
  esw:eslint-help Parsing --help +0ms
  esw:eslint-help Alias found: -v +0ms
  esw:eslint-help Parsing --version +1ms
  esw:eslint-help Parsing --print-config +1ms
  esw:watcher Loaded +0ms
  esw:arg-parser Loaded +0ms
  esw:esw-cli Loaded +0ms
  esw:esw-cli Eslint-Watch: 3.1.3 +0ms
  esw:esw-cli Arguments passed: [ 'C:\\Program Files\\nodejs\\node.exe', 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\node_modules\\eslint-watch\\bin\\esw', '-w', '--fix' ] +0ms
  esw:esw-cli Parsing args +2ms
  esw:arg-parser Directories to check: [] +4ms
  esw:arg-parser Args [ '-w', '--fix' ] +0ms
  esw:arg-parser Pushing item: --fix +0ms
  esw:arg-parser setting custom formatter +1ms
  esw:arg-parser GetPath: simple-detail +0ms
  esw:arg-parser C:\Users\Ronan\Desktop\hot-reloading-boilerplate-redux\node_modules\eslint-watch\build\formatters\simple-detail +0ms
  esw:arg-parser Setting default path: ./ +0ms
  esw:esw-cli Running initial lint +3ms
  esw:esw-cli [ '--fix',
  esw:esw-cli   '-f',
  esw:esw-cli   'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\node_modules\\eslint-watch\\build\\formatters\\simple-detail',
  esw:esw-cli   './' ] +0ms
  esw:eslint-cli eslint: '--fix -f C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\node_modules\\eslint-watch\\build\\formatters\\simple-detail ./' +280ms
  esw:executor node_modules\.bin\eslint.cmd [ '--fix',
  '-f',
  'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\node_modules\\eslint-watch\\build\\formatters\\simple-detail',
  './' ] +821ms
  esw:simple-detail loaded +0ms
  esw:simple-detail [ { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\src\\client\\index.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\src\\common\\app.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\src\\dev\\index.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\src\\index.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\src\\server\\index.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\src\\server\\routes\\foo.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\src\\server\\routes\\index.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\test\\back-end\\index.test.js',
  esw:simple-detail     messages: [ [Object] ],
  esw:simple-detail     errorCount: 1,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0,
  esw:simple-detail     source: 'import { expect } from "chai";\r\nimport sinon from "sinon";\r\n\r\ndescribe("foo", () => {\r\n    it("should say foo", () => {\r\n        expect("foo").to.equal("foo");\r\n    });\r\n    it("should say foo foo", () => {\r\n        expect("fail").to.equal("foo foo");\r\n    });\r\n});\r\n' },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\test\\front-end\\index.test.js',
  esw:simple-detail     messages: [ [Object] ],
  esw:simple-detail     errorCount: 1,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0,
  esw:simple-detail     source: 'import { expect } from "chai";\r\nimport sinon from "sinon";\r\n\r\ndescribe("front-end", () => {\r\n    it("should say bar", () => {\r\n        expect("bar").to.equal("bar");\r\n    });\r\n    it("should say bar bar", () => {\r\n        expect("fail").to.equal("bar bar");\r\n    });\r\n});\r\n' },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\webpack\\back-end\\webpack.common.babel.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\webpack\\back-end\\webpack.dev.babel.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\webpack\\back-end\\webpack.prod.babel.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\webpack\\front-end\\webpack.common.babel.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\webpack\\front-end\\webpack.dev.babel.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\webpack\\front-end\\webpack.prod.babel.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\webpack\\full-stack\\webpack.babel.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  esw:simple-detail   { filePath: 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux\\webpack\\full-stack\\webpack.common.babel.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 } ] +5ms
C:\Users\Ronan\Desktop\hot-reloading-boilerplate-redux\test\back-end\index.test.js (1/0)
  ✖  2:8  'sinon' is defined but never used  no-unused-vars

C:\Users\Ronan\Desktop\hot-reloading-boilerplate-redux\test\front-end\index.test.js (1/0)
  ✖  2:8  'sinon' is defined but never used  no-unused-vars

✖ 2 errors (19:27:21)

  esw:eslint-cli { exitCode: 1, message: '' } +2s
  esw:esw-cli lint completed. Exit Code: 1 +2s

  esw:esw-cli -w seen +1ms
  esw:watcher { useEslintrc: true,
  esw:watcher   ignore: true,
  esw:watcher   fix: true,
  esw:watcher   format: 'simple-detail' } +2s
  esw:watcher { watch: true,
  esw:watcher   fix: true,
  esw:watcher   format: 'simple-detail',
  esw:watcher   eslintrc: true,
  esw:watcher   ignore: true,
  esw:watcher   inlineConfig: true,
  esw:watcher   _: [] } +0ms
  esw:watcher Trying to load formatter for re-lint from ./formatters/simple-detail +2ms
  esw:simple-detail loaded +0ms
  esw:watcher Watching: [ 'C:\\Users\\Ronan\\Desktop\\hot-reloading-boilerplate-redux' ] +31ms
  esw:esw-cli c was pressed +23s
  esw:esw-cli Exiting: 1 +1ms
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! isomorphic-hot-reloading-boilerplate@1.0.0 watch:lint: `cross-env DEBUG=esw:* node node_modules/eslint-watch/bin/esw -w --fix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the isomorphic-hot-reloading-boilerplate@1.0.0 watch:lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Ronan\AppData\Roaming\npm-cache\_logs\2018-03-28T18_27_44_316Z-debug.log
rizowski commented 6 years ago

Thanks for the details. It looks like it ran correctly. So just to be clear what are you expecting to happen V.S. what is happening? Can you give me any more details?

I am running a build that is including node 9 for linux and Windows to see if any of the tests fail.

RonanQuigley commented 6 years ago

Basically everything runs fine when eslint-watch is ran. The only issue that arises is when you quit the program via ctrl + c in the terminal. So for whatever reason, the program crashes when you utilise that exitCode variable on the 'exit' event. Remove it and it works fine.

It's odd as I've used variables inside process.on('exit') before and they've never crashed node. So unsure what's what.

rizowski commented 6 years ago

You might be seeing this issue #125 . Is it crashing every time you exit or does it crash only when you exit after it detects errors? For example,

Does it still crash?

RonanQuigley commented 6 years ago

Yes that is the issue; the errors have now gone. I take it this is by design then?

RonanQuigley commented 6 years ago

So I also ran the watcher with an already existing linting error, removed the linting error, but the program still exits with what looks like a crash.

It seems to me like that issue you referenced is still present, though that proposed solution I think would be confusing. When your code exits with an npm life cycle error, it makes me think that there is something wrong with the actual program as opposed to the watcher correctly identifying linting errors. I don't know the inner workings of your module, but my suggestion would be rather than use a process.exit code that isn't zero, why not just display a console message that summarises existing errors in a formatted way that a developer should consider fixing? You could even just use your error cross mark that you use when linting errors occur, but also use them on exit? The same principle could apply when there is errors to fix by using clean.

capture

rizowski commented 6 years ago

At least in watch mode, the exit code isn't as big of a deal to report due to it being a longer running process and running multiple actions. Given that, if the watch flag was passed I could always return an exit code of 0.

Eslint-watch needs to return a non 0 exit code if --watch isn't passed and if errors are detected so that way CI or chained commands (esw && mocha) appropriately exit.

I could also be exiting incorrectly. I could try playing around with exiting like this approach. My current approach is forcing the node process to halt immediately which might be generating a stack trace which seems like the execution of the application failed, when it really is just reporting an error code. (Both ways might produce the same result.)

RonanQuigley commented 6 years ago

Ah yeah, I see where you're coming from with that. So I'm just using the module in watch mode, so am unsure about the other option.

For me it just boils down to a formatting issue; if both scenarios had final logging that didn't look like a typical node stack trace, then that would make it much clearer as to what's actually going on. Whilst you consider options, I'll stick with using my fork for the time being. Not sure if this is of use, but have you considered using 'SIGINT'? It listens for the ctrl + c event. https://nodejs.org/api/process.html

Sorry I can't be more help with it, node internals are a bit out of my depth. Though if you need me to test whatever solution you come up with, just let me know.

rizowski commented 5 years ago

@RonanQuigley I've recently released V5 of esw. I ended up change how exit codes are passed around. Could you check to see if this is still an issue?

rizowski commented 5 years ago

Closing this for now. If this is still an issue I am willing to reopen to discuss.