-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial import, published to npm already.
- Loading branch information
0 parents
commit e09c5a5
Showing
4 changed files
with
92 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,14 @@ | ||
var npmwrapper = require('npm-wrapper').npmwrapper; | ||
|
||
var base_path = '/tmp/npm_test_1'; | ||
var root_path = base_path + '/.root_path'; | ||
var binroot_path = base_path + '/.bin_path'; | ||
var manroot_path = base_path + '/.man_path'; | ||
var action = 'install'; | ||
var package = 'express'; | ||
|
||
var n = new npmwrapper(); | ||
n.setup(root_path, binroot_path, manroot_path, action, package); | ||
n.run(function (out) { | ||
console.log(out); | ||
}); |
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,51 @@ | ||
var npm = require('npm'); | ||
|
||
var npmwrapper = function () { | ||
this.config = {}; | ||
this.command = ""; | ||
this.package = ""; | ||
this.output = ""; | ||
}; | ||
|
||
npmwrapper.prototype.setup = function (root_path, binroot_path, manroot_path, command, package) { | ||
process.env.PATH = binroot_path + ":" + process.env.PATH; | ||
this.command = command; | ||
this.package = package; | ||
this.config = { | ||
color: false, | ||
root: root_path, | ||
binroot: binroot_path, | ||
manroot: manroot_path, | ||
argv: { | ||
remain: [ package ], | ||
cooked: [ | ||
command, | ||
package, | ||
'--root', | ||
root_path, | ||
'--binroot', | ||
binroot_path, | ||
'--manpath', | ||
manroot_path | ||
], | ||
original: [ ] | ||
} | ||
}; | ||
this.config.argv.original = this.config.argv.cooked; | ||
}; | ||
|
||
npmwrapper.prototype.run = function (cb) { | ||
var self = this; | ||
npm.on('output', function (obj) { | ||
self.output += obj.message + "\n"; | ||
npm.output = false; | ||
}); | ||
npm.load(self.config, function (err) { | ||
if (err) console.log(err); | ||
npm.commands[self.command](self.config.argv.remain, function (err, data) { | ||
cb(self.output); | ||
}); | ||
}); | ||
}; | ||
|
||
exports.npmwrapper = npmwrapper; |
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 @@ | ||
{ | ||
"name": "npm-wrapper", | ||
"description": "A dumb class wrapper around npm to make it easy to manage stuff.", | ||
"version": "0.0.1", | ||
"homepage": "https://github.com/DanBUK/npm-wrapper", | ||
"repository": "git://github.com/DanBUK/npm-wrapper.git", | ||
"author": "Daniel Bartlett <dan@f-box.org> (https://github.com/DanBUK)", | ||
"main": "./npm-wrapper", | ||
"directories": { | ||
"lib": "" | ||
}, | ||
"engines": { | ||
"node": "*" | ||
} | ||
} |
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,12 @@ | ||
npm-wrapper | ||
|
||
A very dump module to make using npm from scripts a little eaiser. | ||
|
||
Please see example.js for how to use. | ||
|
||
npmwrapper methods: | ||
setup - Setup the job you want to run | ||
run - Run the job with a callback with one argument with the output | ||
|
||
Installation | ||
> npm install npm-wrapper |