mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-24 08:35:19 -04:00
Add tests
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
node_modules
|
||||
fixtures
|
||||
.tmp
|
||||
|
||||
@@ -36,16 +36,19 @@ const cli = require('meow')([
|
||||
* Perform
|
||||
*/
|
||||
|
||||
if (!module.parent) {
|
||||
function run (cli) {
|
||||
var ctx = {}
|
||||
|
||||
getPath()
|
||||
return getPath()
|
||||
.then(path => updateContext(path))
|
||||
.then(_ => installMultiple(ctx, cli.input, join(ctx.root, 'node_modules'), cli.flags))
|
||||
.catch(require('../lib/err'))
|
||||
|
||||
function updateContext (root) {
|
||||
ctx.root = root
|
||||
ctx.tmp = join(root, 'node_modules', '.tmp')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = run
|
||||
|
||||
if (!module.parent) run(cli).catch(require('../lib/err'))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
todo:
|
||||
|
||||
- [ ] put in proper node_modules
|
||||
- [ ] dedupe by default
|
||||
- [x] put in proper node_modules
|
||||
- [ ] npm install "rimraf@>2 <3"
|
||||
- [ ] scoped modules
|
||||
|
||||
how it should look like:
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "node test | tap-spec"
|
||||
},
|
||||
"author": "Rico Sta. Cruz <rico@ricostacruz.com>",
|
||||
"license": "MIT",
|
||||
@@ -27,8 +27,12 @@
|
||||
"unpm-install": "bin/unpm-install"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rstacruz/tap-spec": "4.1.1",
|
||||
"debug": "2.2.0",
|
||||
"mkdirp": "0.5.1",
|
||||
"nixt": "0.5.0",
|
||||
"sepia": "2.0.1",
|
||||
"tape": "4.4.0",
|
||||
"thenify": "3.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
29
test/index.js
Normal file
29
test/index.js
Normal file
@@ -0,0 +1,29 @@
|
||||
var test = require('tape')
|
||||
var join = require('path').join
|
||||
var prepare = require('./support/prepare')
|
||||
require('./support/sepia')
|
||||
|
||||
test('small with dependencies (rimraf)', function (t) {
|
||||
prepare()
|
||||
require('../bin/unpm-install')({
|
||||
input: ['rimraf@2.5.1']
|
||||
})
|
||||
.then(function (res) {
|
||||
var rimraf = require(join(process.cwd(), 'node_modules', 'rimraf'))
|
||||
t.ok(typeof rimraf === 'function', 'rimraf is available')
|
||||
t.end()
|
||||
}, t.end)
|
||||
})
|
||||
|
||||
test('no dependencies (lodash)', function (t) {
|
||||
prepare()
|
||||
require('../bin/unpm-install')({
|
||||
input: ['lodash@4.0.0']
|
||||
})
|
||||
.then(function (res) {
|
||||
var _ = require(join(process.cwd(), 'node_modules', 'lodash'))
|
||||
t.ok(typeof _ === 'function', '_ is available')
|
||||
t.ok(typeof _.clone === 'function', '_.clone is available')
|
||||
t.end()
|
||||
}, t.end)
|
||||
})
|
||||
13
test/support/prepare.js
Normal file
13
test/support/prepare.js
Normal file
@@ -0,0 +1,13 @@
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
var fs = require('fs')
|
||||
var join = require('path').join
|
||||
var root = process.cwd()
|
||||
process.env.ROOT = root
|
||||
|
||||
module.exports = function prepare () {
|
||||
rimraf.sync(join(root, '.tmp'))
|
||||
mkdirp.sync(join(root, '.tmp'))
|
||||
fs.writeFileSync(join(root, '.tmp', 'package.json'), '{}', 'utf-8')
|
||||
process.chdir(join(root, '.tmp'))
|
||||
}
|
||||
3
test/support/sepia.js
Normal file
3
test/support/sepia.js
Normal file
@@ -0,0 +1,3 @@
|
||||
process.env.VCR_MODE = 'cache'
|
||||
require('sepia')
|
||||
|
||||
Reference in New Issue
Block a user