diff options
author | Jussi Kalliokoski <jussi.kalliokoski@gmail.com> | 2014-09-14 23:10:11 +0400 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2014-09-16 04:22:03 +0400 |
commit | b706d637d5965dbf8f7ce07dc5c4bc80887f30d8 (patch) | |
tree | bb05a1aa514ac9595bc16d0d90a84bc5bc35eb0a /test | |
parent | 119f068eae2a36fa8b9c9ca557c70377792243a4 (diff) |
Disabled `prepublish` when running production mode install.
See discussion in #3059.
Diffstat (limited to 'test')
-rw-r--r-- | test/tap/install-cli-production.js | 46 | ||||
-rw-r--r-- | test/tap/install-cli-production/dependency/package.json | 5 | ||||
-rw-r--r-- | test/tap/install-cli-production/dev-dependency/package.json | 5 | ||||
-rw-r--r-- | test/tap/install-cli-production/package.json | 14 |
4 files changed, 70 insertions, 0 deletions
diff --git a/test/tap/install-cli-production.js b/test/tap/install-cli-production.js new file mode 100644 index 000000000..75d5f7e23 --- /dev/null +++ b/test/tap/install-cli-production.js @@ -0,0 +1,46 @@ +var common = require('../common-tap.js') +var test = require('tap').test +var npm = require('../../') +var path = require('path') +var fs = require('fs') +var rimraf = require('rimraf') +var mkdirp = require('mkdirp') +var pkg = path.join(__dirname, 'install-cli-production') + +test("setup", function(t) { + mkdirp.sync(pkg) + mkdirp.sync(path.resolve(pkg, 'node_modules')) + process.chdir(pkg) + t.end() +}) + +test('"npm install --production" should install dependencies', function(t) { + npm.load(function() { + npm.config.set('production', true) + npm.commands.install([], function(err) { + if (err) return t.fail(err) + var p = path.resolve(pkg, 'node_modules/dependency/package.json') + t.ok(JSON.parse(fs.readFileSync(p, 'utf8'))) + t.end() + }) + }) +}) + +test('"npm install --production" should not install dev dependencies', function(t) { + npm.load(function() { + npm.config.set('production', true) + npm.commands.install([], function(err) { + if (err) return t.fail(err) + var p = path.resolve(pkg, 'node_modules/dev-dependency/package.json') + t.ok(!fs.existsSync(p), '') + t.end() + }) + }) +}) + +test('cleanup', function(t) { + process.chdir(__dirname) + rimraf.sync(path.resolve(pkg, 'node_modules')) + t.end() +}) + diff --git a/test/tap/install-cli-production/dependency/package.json b/test/tap/install-cli-production/dependency/package.json new file mode 100644 index 000000000..6ee6be0c3 --- /dev/null +++ b/test/tap/install-cli-production/dependency/package.json @@ -0,0 +1,5 @@ +{ + "name": "dependency", + "description": "fixture", + "version": "0.0.0" +} diff --git a/test/tap/install-cli-production/dev-dependency/package.json b/test/tap/install-cli-production/dev-dependency/package.json new file mode 100644 index 000000000..a6a8f6976 --- /dev/null +++ b/test/tap/install-cli-production/dev-dependency/package.json @@ -0,0 +1,5 @@ +{ + "name": "dev-dependency", + "description": "fixture", + "version": "0.0.0" +} diff --git a/test/tap/install-cli-production/package.json b/test/tap/install-cli-production/package.json new file mode 100644 index 000000000..8f2f0e2ec --- /dev/null +++ b/test/tap/install-cli-production/package.json @@ -0,0 +1,14 @@ +{ + "name": "install-cli-production", + "description": "fixture", + "version": "0.0.0", + "scripts": { + "prepublish": "exit 123" + }, + "dependencies": { + "dependency": "file:./dependency" + }, + "devDependencies": { + "dev-dependency": "file:./dev-dependency" + } +} |