summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/run-script.js
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2016-03-29 23:30:51 -0700
committerMyles Borins <mborins@us.ibm.com>2016-04-01 14:47:39 -0700
commit0928584444ac6edf1ead0b93c9d05b1124183702 (patch)
treef64c5646b8e2817009e7afe97c2670c73d38a7eb /deps/npm/test/tap/run-script.js
parent39de601e1c3eda92eb2e37eca4e6aa960f206f39 (diff)
downloadandroid-node-v8-0928584444ac6edf1ead0b93c9d05b1124183702.tar.gz
android-node-v8-0928584444ac6edf1ead0b93c9d05b1124183702.tar.bz2
android-node-v8-0928584444ac6edf1ead0b93c9d05b1124183702.zip
deps: upgrade npm to 3.8.3
PR-URL: https://github.com/npm/node/pull/6 Reviewed-By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'deps/npm/test/tap/run-script.js')
-rw-r--r--deps/npm/test/tap/run-script.js67
1 files changed, 65 insertions, 2 deletions
diff --git a/deps/npm/test/tap/run-script.js b/deps/npm/test/tap/run-script.js
index d7087693df..3892337cee 100644
--- a/deps/npm/test/tap/run-script.js
+++ b/deps/npm/test/tap/run-script.js
@@ -25,8 +25,13 @@ var fullyPopulated = {
'prewith-both': 'node -e "console.log(process.argv[1] || \'pre\')"',
'with-both': 'node -e "console.log(process.argv[1] || \'main\')"',
'postwith-both': 'node -e "console.log(process.argv[1] || \'post\')"',
- 'stop': 'node -e "console.log(process.argv[1] || \'stop\')"'
- }
+ 'stop': 'node -e "console.log(process.argv[1] || \'stop\')"',
+ 'env-vars': 'node -e "console.log(process.env.run_script_foo_var)"',
+ 'npm-env-vars': 'node -e "console.log(process.env.npm_run_script_foo_var)"',
+ 'package-env-vars': 'node -e "console.log(process.env.run_script_foo_var)"',
+ 'prefixed-package-env-vars': 'node -e "console.log(process.env.npm_package_run_script_foo_var)"'
+ },
+ 'run_script_foo_var': 'run_script_test_foo_val'
}
var lifecycleOnly = {
@@ -180,6 +185,64 @@ test('npm run-script nonexistent-script with --if-present flag', function (t) {
})
})
+test('npm run-script env vars accessible', function (t) {
+ process.env.run_script_foo_var = 'run_script_test_foo_val'
+ common.npm(['run-script', 'env-vars'], {
+ cwd: pkg
+ }, function (err, code, stdout, stderr) {
+ t.ifError(err, 'ran run-script without crashing')
+ t.equal(code, 0, 'exited normally')
+ t.equal(stderr, '', 'no error output')
+ t.match(stdout,
+ new RegExp(process.env.run_script_foo_var),
+ 'script had env access')
+ t.end()
+ })
+})
+
+test('npm run-script package.json vars injected', function (t) {
+ common.npm(['run-script', 'package-env-vars'], {
+ cwd: pkg
+ }, function (err, code, stdout, stderr) {
+ t.ifError(err, 'ran run-script without crashing')
+ t.equal(code, 0, 'exited normally')
+ t.equal(stderr, '', 'no error output')
+ t.match(stdout,
+ new RegExp(fullyPopulated.run_script_foo_var),
+ 'script injected package.json value')
+ t.end()
+ })
+})
+
+test('npm run-script package.json vars injected with prefix', function (t) {
+ common.npm(['run-script', 'prefixed-package-env-vars'], {
+ cwd: pkg
+ }, function (err, code, stdout, stderr) {
+ t.ifError(err, 'ran run-script without crashing')
+ t.equal(code, 0, 'exited normally')
+ t.equal(stderr, '', 'no error output')
+ t.match(stdout,
+ new RegExp(fullyPopulated.run_script_foo_var),
+ 'script injected npm_package-prefixed package.json value')
+ t.end()
+ })
+})
+
+test('npm run-script env vars stripped npm-prefixed', function (t) {
+ process.env.npm_run_script_foo_var = 'run_script_test_foo_val'
+ common.npm(['run-script', 'npm-env-vars'], {
+ cwd: pkg
+ }, function (err, code, stdout, stderr) {
+ t.ifError(err, 'ran run-script without crashing')
+ t.equal(code, 0, 'exited normally')
+ t.equal(stderr, '', 'no error output')
+ t.notMatch(stdout,
+ new RegExp(process.env.npm_run_script_foo_var),
+ 'script stripped npm-prefixed env var')
+ t.end()
+ })
+})
+
test('npm run-script no-params (lifecycle only)', function (t) {
var expected = [
'Lifecycle scripts included in scripted:',