diff options
Diffstat (limited to 'deps/npm/test/tap/install-save-prefix.js')
-rw-r--r-- | deps/npm/test/tap/install-save-prefix.js | 122 |
1 files changed, 60 insertions, 62 deletions
diff --git a/deps/npm/test/tap/install-save-prefix.js b/deps/npm/test/tap/install-save-prefix.js index 0e78005b6e..d4efef4b61 100644 --- a/deps/npm/test/tap/install-save-prefix.js +++ b/deps/npm/test/tap/install-save-prefix.js @@ -1,39 +1,39 @@ -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-save-prefix') +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-save-prefix") var mr = require("npm-registry-mock") test("setup", function (t) { mkdirp.sync(pkg) - mkdirp.sync(path.resolve(pkg, 'node_modules')) + mkdirp.sync(path.resolve(pkg, "node_modules")) process.chdir(pkg) t.end() }) -test('"npm install --save with default save-prefix should install local pkg versioned to allow minor updates', function(t) { +test("npm install --save with default save-prefix should install local pkg versioned to allow minor updates", function (t) { resetPackageJSON(pkg) mr(common.port, function (s) { npm.load({ cache: pkg + "/cache", - loglevel: 'silent', - 'save-prefix': '^', - registry: common.registry }, function(err) { + loglevel: "silent", + "save-prefix": "^", + registry: common.registry }, function (err) { t.ifError(err) - npm.config.set('save', true) - npm.commands.install(['underscore@latest'], function(err) { + npm.config.set("save", true) + npm.commands.install(["underscore@latest"], function (err) { t.ifError(err) - var p = path.resolve(pkg, 'node_modules/underscore/package.json') + var p = path.resolve(pkg, "node_modules/underscore/package.json") t.ok(JSON.parse(fs.readFileSync(p))) - var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8')) + var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8")) t.deepEqual(pkgJson.dependencies, { - 'underscore': '^1.5.1' - }, 'Underscore dependency should specify ^1.5.1') - npm.config.set('save', undefined) + "underscore": "^1.5.1" + }, "Underscore dependency should specify ^1.5.1") + npm.config.set("save", undefined) s.close() t.end() }) @@ -41,25 +41,25 @@ test('"npm install --save with default save-prefix should install local pkg vers }) }) -test('"npm install --save-dev with default save-prefix should install local pkg to dev dependencies versioned to allow minor updates', function(t) { +test("npm install --save-dev with default save-prefix should install local pkg to dev dependencies versioned to allow minor updates", function (t) { resetPackageJSON(pkg) mr(common.port, function (s) { npm.load({ cache: pkg + "/cache", - loglevel: 'silent', - 'save-prefix': '^', - registry: common.registry }, function(err) { + loglevel: "silent", + "save-prefix": "^", + registry: common.registry }, function (err) { t.ifError(err) - npm.config.set('save-dev', true) - npm.commands.install(['underscore@1.3.1'], function(err) { + npm.config.set("save-dev", true) + npm.commands.install(["underscore@1.3.1"], function (err) { t.ifError(err) - var p = path.resolve(pkg, 'node_modules/underscore/package.json') + var p = path.resolve(pkg, "node_modules/underscore/package.json") t.ok(JSON.parse(fs.readFileSync(p))) - var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8')) + var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8")) t.deepEqual(pkgJson.devDependencies, { - 'underscore': '^1.3.1' - }, 'Underscore devDependency should specify ^1.3.1') - npm.config.set('save-dev', undefined) + "underscore": "^1.3.1" + }, "Underscore devDependency should specify ^1.3.1") + npm.config.set("save-dev", undefined) s.close() t.end() }) @@ -67,26 +67,26 @@ test('"npm install --save-dev with default save-prefix should install local pkg }) }) -test('"npm install --save with "~" save-prefix should install local pkg versioned to allow patch updates', function(t) { +test("npm install --save with \"~\" save-prefix should install local pkg versioned to allow patch updates", function (t) { resetPackageJSON(pkg) mr(common.port, function (s) { npm.load({ cache: pkg + "/cache", - loglevel: 'silent', - registry: common.registry }, function(err) { + loglevel: "silent", + registry: common.registry }, function (err) { t.ifError(err) - npm.config.set('save', true) - npm.config.set('save-prefix', '~') - npm.commands.install(['underscore@1.3.1'], function(err) { + npm.config.set("save", true) + npm.config.set("save-prefix", "~") + npm.commands.install(["underscore@1.3.1"], function (err) { t.ifError(err) - var p = path.resolve(pkg, 'node_modules/underscore/package.json') + var p = path.resolve(pkg, "node_modules/underscore/package.json") t.ok(JSON.parse(fs.readFileSync(p))) - var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8')) + var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8")) t.deepEqual(pkgJson.dependencies, { - 'underscore': '~1.3.1' - }, 'Underscore dependency should specify ~1.3.1') - npm.config.set('save', undefined) - npm.config.set('save-prefix', undefined) + "underscore": "~1.3.1" + }, "Underscore dependency should specify ~1.3.1") + npm.config.set("save", undefined) + npm.config.set("save-prefix", undefined) s.close() t.end() }) @@ -94,26 +94,26 @@ test('"npm install --save with "~" save-prefix should install local pkg versione }) }) -test('"npm install --save-dev with "~" save-prefix should install local pkg to dev dependencies versioned to allow patch updates', function(t) { +test("npm install --save-dev with \"~\" save-prefix should install local pkg to dev dependencies versioned to allow patch updates", function (t) { resetPackageJSON(pkg) mr(common.port, function (s) { npm.load({ cache: pkg + "/cache", - loglevel: 'silent', - registry: common.registry }, function(err) { + loglevel: "silent", + registry: common.registry }, function (err) { t.ifError(err) - npm.config.set('save-dev', true) - npm.config.set('save-prefix', '~') - npm.commands.install(['underscore@1.3.1'], function(err) { + npm.config.set("save-dev", true) + npm.config.set("save-prefix", "~") + npm.commands.install(["underscore@1.3.1"], function (err) { t.ifError(err) - var p = path.resolve(pkg, 'node_modules/underscore/package.json') + var p = path.resolve(pkg, "node_modules/underscore/package.json") t.ok(JSON.parse(fs.readFileSync(p))) - var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8')) + var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8")) t.deepEqual(pkgJson.devDependencies, { - 'underscore': '~1.3.1' - }, 'Underscore devDependency should specify ~1.3.1') - npm.config.set('save-dev', undefined) - npm.config.set('save-prefix', undefined) + "underscore": "~1.3.1" + }, "Underscore devDependency should specify ~1.3.1") + npm.config.set("save-dev", undefined) + npm.config.set("save-prefix", undefined) s.close() t.end() }) @@ -121,21 +121,19 @@ test('"npm install --save-dev with "~" save-prefix should install local pkg to d }) }) -test('cleanup', function(t) { +test("cleanup", function (t) { process.chdir(__dirname) - rimraf.sync(path.resolve(pkg, 'node_modules')) - rimraf.sync(path.resolve(pkg, 'cache')) + rimraf.sync(path.resolve(pkg, "node_modules")) + rimraf.sync(path.resolve(pkg, "cache")) resetPackageJSON(pkg) t.end() }) function resetPackageJSON(pkg) { - var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8')) + var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8")) delete pkgJson.dependencies delete pkgJson.devDependencies delete pkgJson.optionalDependencies var json = JSON.stringify(pkgJson, null, 2) + "\n" - fs.writeFileSync(pkg + '/package.json', json, "ascii") + fs.writeFileSync(pkg + "/package.json", json, "ascii") } - - |