summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/install-windows-newlines.js
diff options
context:
space:
mode:
authorMyles Borins <myles.borins@gmail.com>2017-10-26 22:35:25 -0400
committerMyles Borins <myles.borins@gmail.com>2017-10-29 21:32:15 -0400
commitace4fe566fc3af4876c7458f983feeb5eae3df26 (patch)
tree458d847e9bd56199cd0d8b34cec126c7410fb6ca /deps/npm/test/tap/install-windows-newlines.js
parent64168eb9b43e30e4c0b986c9b29c41be63e85df6 (diff)
downloadandroid-node-v8-ace4fe566fc3af4876c7458f983feeb5eae3df26.tar.gz
android-node-v8-ace4fe566fc3af4876c7458f983feeb5eae3df26.tar.bz2
android-node-v8-ace4fe566fc3af4876c7458f983feeb5eae3df26.zip
deps: update npm to 5.5.1
Closes: https://github.com/nodejs/node/pull/16280 PR-URL: https://github.com/nodejs/node/pull/16509 Fixes: https://github.com/nodejs/node/issues/14161 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'deps/npm/test/tap/install-windows-newlines.js')
-rw-r--r--deps/npm/test/tap/install-windows-newlines.js90
1 files changed, 90 insertions, 0 deletions
diff --git a/deps/npm/test/tap/install-windows-newlines.js b/deps/npm/test/tap/install-windows-newlines.js
new file mode 100644
index 0000000000..56ef172a29
--- /dev/null
+++ b/deps/npm/test/tap/install-windows-newlines.js
@@ -0,0 +1,90 @@
+var fs = require('graceful-fs')
+var path = require('path')
+var existsSync = fs.existsSync || path.existsSync
+
+var mkdirp = require('mkdirp')
+var rimraf = require('rimraf')
+var test = require('tap').test
+
+var common = require('../common-tap.js')
+
+var pkg = path.join(__dirname, 'install-windows-newlines')
+
+var EXEC_OPTS = { cwd: pkg, stdio: [0, 1, 2] }
+
+var json = {
+ name: 'install-windows-newlines',
+ description: 'fixture',
+ version: '0.0.0',
+ dependencies: {
+ 'cli-dependency': 'file:cli-dependency'
+ }
+}
+
+var dependency = {
+ name: 'cli-dependency',
+ description: 'fixture',
+ version: '0.0.0',
+ bin: {
+ hashbang: './hashbang.js',
+ nohashbang: './nohashbang.js'
+ }
+}
+
+test('setup', function (t) {
+ cleanup()
+ mkdirp.sync(path.join(pkg, 'cli-dependency'))
+ fs.writeFileSync(
+ path.join(pkg, 'cli-dependency', 'package.json'),
+ JSON.stringify(dependency, null, 2)
+ )
+ fs.writeFileSync(
+ path.join(pkg, 'cli-dependency', 'hashbang.js'),
+ '#!/usr/bin/env node\r\nconsole.log(\'Hello, world!\')\r\n'
+ )
+ fs.writeFileSync(
+ path.join(pkg, 'cli-dependency', 'nohashbang.js'),
+ '\'use strict\'\r\nconsole.log(\'Goodbye, world!\')\r\n'
+ )
+
+ mkdirp.sync(path.join(pkg, 'node_modules'))
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ JSON.stringify(json, null, 2)
+ )
+
+ return common.npm(['install'], EXEC_OPTS).spread((code) => {
+ t.equal(code, 0, 'npm install did not raise error code')
+ t.ok(
+ existsSync(path.resolve(pkg, 'node_modules/.bin/hashbang')),
+ 'hashbang installed'
+ )
+ t.ok(
+ existsSync(path.resolve(pkg, 'node_modules/.bin/nohashbang')),
+ 'nohashbang installed'
+ )
+ t.notOk(
+ fs.readFileSync(
+ path.resolve(pkg, 'node_modules/cli-dependency/hashbang.js'),
+ 'utf8'
+ ).includes('\r\n'),
+ 'hashbang dependency cli newlines converted'
+ )
+ t.ok(
+ fs.readFileSync(
+ path.resolve(pkg, 'node_modules/cli-dependency/nohashbang.js'),
+ 'utf8'
+ ).includes('\r\n'),
+ 'nohashbang dependency cli newlines retained'
+ )
+ })
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.end()
+})
+
+function cleanup () {
+ rimraf.sync(pkg)
+}