coa 1.0.2 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-present Sergey Berezhnoy <veged@ya.ru>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/lib/cmd.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable class-methods-use-this */
1
2
  'use strict';
2
3
 
3
4
  const
@@ -191,9 +192,9 @@ class Cmd extends CoaObject {
191
192
  }
192
193
 
193
194
  _exit(msg, code) {
194
- return process.once('exit', function() {
195
- msg && console.error(msg);
196
- return process.exit(code || 0);
195
+ return process.once('exit', function(exitCode) {
196
+ msg && console[code === 0 ? 'log' : 'error'](msg);
197
+ process.exit(code || exitCode || 0);
197
198
  });
198
199
  }
199
200
 
@@ -430,7 +431,7 @@ class Cmd extends CoaObject {
430
431
 
431
432
  const cb = code =>
432
433
  res => res?
433
- this._exit(res.stack || res.toString(), res.exitCode || code) :
434
+ this._exit(res.stack || res.toString(), (res.hasOwnProperty('exitCode')? res.exitCode : code) || 0) :
434
435
  this._exit();
435
436
 
436
437
  Q.when(this.do(argv), cb(0), cb(1)).done();
package/lib/coaobject.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable class-methods-use-this */
1
2
  'use strict';
2
3
 
3
4
  const Q = require('q');
package/lib/completion.js CHANGED
@@ -62,7 +62,7 @@ function dumpScript(name) {
62
62
 
63
63
  fs.readFile(path.resolve(__dirname, 'completion.sh'), 'utf8', function(err, d) {
64
64
  if(err) return defer.reject(err);
65
- d = d.replace(/{{cmd}}/g, path.basename(name)).replace(/^\#\!.*?\n/, '');
65
+ d = d.replace(/{{cmd}}/g, path.basename(name)).replace(/^#!.*?\n/, '');
66
66
 
67
67
  process.stdout.on('error', onError);
68
68
  process.stdout.write(d, () => defer.resolve());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "coa",
3
3
  "description": "Command-Option-Argument: Yet another parser for command line options.",
4
- "version": "1.0.2",
4
+ "version": "2.0.1",
5
5
  "homepage": "http://github.com/veged/coa",
6
6
  "author": "Sergey Berezhnoy <veged@ya.ru> (http://github.com/veged)",
7
7
  "maintainers": [
@@ -29,8 +29,8 @@
29
29
  "devDependencies": {
30
30
  "chai": "~1.7.2",
31
31
  "coveralls": "^2.11.16",
32
- "eslint": "^3.15.0",
33
- "eslint-config-pedant": "^0.8.0",
32
+ "eslint": "^4.15.0",
33
+ "eslint-config-pedant": "^1.0.0",
34
34
  "mocha": "~1.21.4",
35
35
  "nyc": "^10.1.2"
36
36
  },