-
-
Notifications
You must be signed in to change notification settings - Fork 944
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4b42e5f
Showing
6 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env node | ||
var readPkgUp = require('read-pkg-up') | ||
var npa = require('npm-package-arg') | ||
var debug = require('debug')('cnpm:install') | ||
var dirname = require('path').dirname | ||
var join = require('path').join | ||
var mkdirp = require('../lib/mkdirp') | ||
|
||
const cli = require('meow')([ | ||
'Usage:', | ||
' $ cnpm install', | ||
' $ cnpm install <name>', | ||
'', | ||
'Options:', | ||
' -D, --save-dev', | ||
' -S, --save', | ||
' -E, --save-exact', | ||
' --dry-run' | ||
].join('\n'), { | ||
boolean: ['save-dev', 'save', 'save-exact', 'dry-run'] | ||
}) | ||
// console.log(cli.flags, cli.input) | ||
|
||
/* | ||
* Installs a package | ||
* | ||
* install(path, 'underscore@latest') | ||
*/ | ||
|
||
function install (modPath, pkg, options) { | ||
debug('installing ' + pkg) | ||
return Promise.resolve(true) | ||
} | ||
|
||
/* | ||
* Install multiple modules | ||
*/ | ||
|
||
function installMultiple (modPath, pkgs, options) { | ||
return Promise.all(pkgs.map(function (pkg) { | ||
return install(modPath, pkg, options) | ||
})) | ||
} | ||
|
||
/* | ||
* Returns the path of package.json | ||
*/ | ||
|
||
function getPath () { | ||
return readPkgUp() | ||
.then(function (pkg) { | ||
debug('root: ' + dirname(pkg.path)) | ||
return dirname(pkg.path) | ||
}) | ||
} | ||
|
||
if (!module.parent) { | ||
getPath() | ||
.then(_ => mkdirp(join(_, 'node_modules'))) | ||
.then(_ => installMultiple(_, cli.input, cli.flags)) | ||
.catch(require('../lib/err')) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = function err (error) { | ||
console.error(err.stack) | ||
process.exit(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var debug = require('debug')('cnpm:mkdirp') | ||
|
||
/* | ||
* mkdir -p as a promise. | ||
*/ | ||
|
||
module.exports = function mkdirp (path) { | ||
return new Promise(function (resolve, reject) { | ||
debug(path) | ||
require('mkdirp')(path, function (err) { | ||
if (err) reject(err) | ||
else resolve(path) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "cnpm", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Rico Sta. Cruz <rico@ricostacruz.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"meow": "3.7.0", | ||
"npm-package-arg": "4.1.0", | ||
"read-pkg-up": "1.0.1" | ||
}, | ||
"bin": { | ||
"cnpm-install": "bin/cnpm-install" | ||
}, | ||
"devDependencies": { | ||
"debug": "2.2.0", | ||
"mkdirp": "0.5.1", | ||
"thenify": "3.1.1" | ||
} | ||
} |