From 2d7050fab4cef1204d16a1f05936d5f85d8fcdcf Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Tue, 2 Feb 2016 01:19:15 +0800 Subject: [PATCH] Expose require('pnpm.js') --- index.js | 10 ++++++++++ lib/cmd/install.js | 2 +- test/index.js | 6 +++--- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000000..4b0d91ca83 --- /dev/null +++ b/index.js @@ -0,0 +1,10 @@ +var pnpm = {} + +Object.defineProperty(pnpm, 'install', { + enumerable: true, + get: function () { + return require('./lib/cmd/install') + } +}) + +module.exports = pnpm diff --git a/lib/cmd/install.js b/lib/cmd/install.js index d322ac05cd..f941a36313 100644 --- a/lib/cmd/install.js +++ b/lib/cmd/install.js @@ -21,7 +21,7 @@ function installCmd (input, flags) { var pkg var packagesToInstall var installType - var isProductionInstall = cli.flags.production || process.env.NODE_ENV === 'production' + var isProductionInstall = flags.production || process.env.NODE_ENV === 'production' return readPkgUp() .then(_ => { pkg = _ }) diff --git a/test/index.js b/test/index.js index 3e972be9c3..155c453ca6 100644 --- a/test/index.js +++ b/test/index.js @@ -3,7 +3,7 @@ var join = require('path').join var fs = require('fs') var prepare = require('./support/prepare') var basicPackageJson = require('./support/simple-package.json') -var install = require('../lib/cmd/install') +var install = require('../index').install require('./support/sepia') var stat, _ @@ -249,7 +249,7 @@ test('production install (with --production flag)', function (t) { prepare() fs.writeFileSync('package.json', JSON.stringify(basicPackageJson), 'utf-8') - return install({ input: [], flags: { quiet: true, production: true } }) + return install([], { quiet: true, production: true }) .then(function () { var rimrafDir = fs.statSync(join(process.cwd(), 'node_modules', 'rimraf')) @@ -271,7 +271,7 @@ test('production install (with production NODE_ENV)', function (t) { prepare() fs.writeFileSync('package.json', JSON.stringify(basicPackageJson), 'utf-8') - return install({ input: [], flags: { quiet: true } }) + return install([], { quiet: true }) .then(function () { // reset NODE_ENV process.env.NODE_ENV = originalNODE_ENV