1
0
mirror of https://github.com/thangisme/notes.git synced 2026-06-16 06:20:14 -04:00

Initial commit

This commit is contained in:
Patrick Marsceill
2017-03-09 13:16:08 -05:00
commit b7b0d0d7bf
4147 changed files with 401224 additions and 0 deletions

64
node_modules/yargs/test/_.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
var spawn = require('child_process').spawn,
should = require('chai').should();
describe('bin script', function () {
it('should run as a shell script with no arguments', function (done) {
testCmd('./bin.js', [], done);
});
it('should run as a shell script with arguments', function (done) {
testCmd('./bin.js', [ 'a', 'b', 'c' ], done);
});
it('should run as a node script with no arguments', function (done) {
testCmd('node bin.js', [], done);
});
it('should run as a node script with arguments', function (done) {
testCmd('node bin.js', [ 'x', 'y', 'z' ], done);
});
describe('path returned by "which"', function () {
beforeEach(function () {
this.which = spawn('which', ['node']);
});
it('should match the actual path to the script file', function (done) {
this.which.stdout.on('data', function (buf) {
testCmd(buf.toString().trim() + ' bin.js', [], done);
});
this.which.stderr.on('data', done);
});
it('should match the actual path to the script file, with arguments', function (done) {
this.which.stdout.on('data', function (buf) {
testCmd(buf.toString().trim() + ' bin.js', [ 'q', 'r' ], done);
});
this.which.stderr.on('data', done);
});
});
});
function testCmd(cmd, args, done) {
var oldDir = process.cwd();
process.chdir(__dirname + '/_');
var cmds = cmd.split(' ');
var bin = spawn(cmds[0], cmds.slice(1).concat(args.map(String)));
process.chdir(oldDir);
bin.stderr.on('data', done);
bin.stdout.on('data', function (buf) {
var _ = JSON.parse(buf.toString());
_.map(String).should.deep.equal(args.map(String));
done();
});
}