X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.maps.server%2Fnode%2Fnode-v4.8.0-win-x64%2Fnode_modules%2Fnpm%2Ftest%2Ftap%2Fignore-scripts.js;fp=org.simantics.maps.server%2Fnode%2Fnode-v4.8.0-win-x64%2Fnode_modules%2Fnpm%2Ftest%2Ftap%2Fignore-scripts.js;h=8c0d350198a29a8dfd37330bad8aacebe1d214a3;hb=2529be6d456deeb07c128603ce4971f1dc29b695;hp=0000000000000000000000000000000000000000;hpb=2636fc31c16c23711cf2b06a4ae8537bba9c1d35;p=simantics%2Fdistrict.git diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/ignore-scripts.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/ignore-scripts.js new file mode 100644 index 00000000..8c0d3501 --- /dev/null +++ b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/ignore-scripts.js @@ -0,0 +1,124 @@ +var fs = require('graceful-fs') +var path = require('path') + +var mkdirp = require('mkdirp') +var rimraf = require('rimraf') +var test = require('tap').test + +var common = require('../common-tap') + +// ignore-scripts/package.json has scripts that always exit with non-zero error +// codes. +var pkg = path.resolve(__dirname, 'ignore-scripts') + +var gypfile = 'bad_binding_file\n' +var json = { + author: 'Milton the Aussie', + name: 'ignore-scripts', + version: '0.0.0', + scripts: { + prepublish: 'exit 123', + publish: 'exit 123', + postpublish: 'exit 123', + preinstall: 'exit 123', + install: 'exit 123', + postinstall: 'exit 123', + preuninstall: 'exit 123', + uninstall: 'exit 123', + postuninstall: 'exit 123', + pretest: 'exit 123', + test: 'exit 123', + posttest: 'exit 123', + prestop: 'exit 123', + stop: 'exit 123', + poststop: 'exit 123', + prestart: 'exit 123', + start: 'exit 123', + poststart: 'exit 123', + prerestart: 'exit 123', + restart: 'exit 123', + postrestart: 'exit 123', + preversion: 'exit 123', + version: 'exit 123', + postversion: 'exit 123' + } +} + +test('setup', function (t) { + setup() + t.end() +}) + +test('ignore-scripts: install using the option', function (t) { + createChild(['install', '--ignore-scripts'], function (err, code) { + t.ifError(err, 'install with scripts ignored finished successfully') + t.equal(code, 0, 'npm install exited with code') + t.end() + }) +}) + +test('ignore-scripts: install NOT using the option', function (t) { + createChild(['install'], function (err, code) { + t.ifError(err, 'install with scripts successful') + t.notEqual(code, 0, 'npm install exited with code') + t.end() + }) +}) + +var scripts = [ + 'prepublish', 'publish', 'postpublish', + 'preinstall', 'install', 'postinstall', + 'preuninstall', 'uninstall', 'postuninstall', + 'pretest', 'test', 'posttest', + 'prestop', 'stop', 'poststop', + 'prestart', 'start', 'poststart', + 'prerestart', 'restart', 'postrestart', + 'preversion', 'version', 'postversion' +] + +scripts.forEach(function (script) { + test('ignore-scripts: run-script ' + script + ' using the option', function (t) { + createChild(['--ignore-scripts', 'run-script', script], function (err, code, stdout, stderr) { + t.ifError(err, 'run-script ' + script + ' with ignore-scripts successful') + t.equal(code, 0, 'npm run-script exited with code') + t.end() + }) + }) +}) + +scripts.forEach(function (script) { + test('ignore-scripts: run-script ' + script + ' NOT using the option', function (t) { + createChild(['run-script', script], function (err, code) { + t.ifError(err, 'run-script ' + script + ' finished successfully') + t.notEqual(code, 0, 'npm run-script exited with code') + t.end() + }) + }) +}) + +test('cleanup', function (t) { + cleanup() + t.end() +}) + +function cleanup () { + rimraf.sync(pkg) +} + +function setup () { + cleanup() + mkdirp.sync(pkg) + fs.writeFileSync(path.join(pkg, 'binding.gyp'), gypfile) + fs.writeFileSync( + path.join(pkg, 'package.json'), + JSON.stringify(json, null, 2) + ) +} + +function createChild (args, cb) { + return common.npm( + args.concat(['--loglevel', 'silent']), + { cwd: pkg }, + cb + ) +}