Skip to content

Commit

Permalink
validate argument length
Browse files Browse the repository at this point in the history
[BREAKING] drop support for Node.js < 6
  • Loading branch information
shinnn committed Jun 18, 2018
1 parent 6ab4de6 commit f815eb5
Show file tree
Hide file tree
Showing 3 changed files with 2,672 additions and 408 deletions.
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
'use strict';

const join = require('path').join;
const {join} = require('path');

const npmCliDir = require('npm-cli-dir');

module.exports = function npmCliVersion() {
module.exports = function npmCliVersion(...args) {
const argLen = args.length;

if (argLen !== 0) {
return Promise.reject(new RangeError(`Expected no arguments, but got ${argLen} argument${
argLen === 1 ? '' : 's'
}.`));
}

return npmCliDir().then(dirPath => {
return require(join(dirPath, './package.json')).version;
return require(join(dirPath, 'package.json')).version;
});
};
Loading

0 comments on commit f815eb5

Please sign in to comment.