From 3176440dfc6ec23a2477d7f27c52c9b6f12b3eda Mon Sep 17 00:00:00 2001 From: deathcap Date: Tue, 10 Feb 2015 22:07:46 -0800 Subject: [PATCH] Add experimental CLI interface, try npm_cli('node', 'npm', 'help', '--long', 'foo') Lots of issues with it GH-8 --- package.json | 3 ++- webnpm.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a257cf2..190ded9 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "wzrd": "^1.2.1", "brfs": "^1.3.0", "through": "^2.3.6", - "browserify-fs": "^1.0.0" + "browserify-fs": "^1.0.0", + "asarray": "^0.1.0" }, "license": "MIT" } diff --git a/webnpm.js b/webnpm.js index eca055a..d06f641 100644 --- a/webnpm.js +++ b/webnpm.js @@ -222,4 +222,13 @@ function main() { console.log('WebNPM loaded. Try browserify() or npm.commands.*()'); }); + + var asarray = require('asarray'); + + global.npm_cli = function() { + // Call the NPM command-line interface with the given function arguments + process.argv = asarray(arguments); // for .slice, on Array but not arguments + require('npm/cli.js'); + // this only works once :( TODO + }; }