Comparing version 0.1.13 to 0.1.14
241
lib/cli.js
@@ -15,6 +15,2 @@ 'use strict'; | ||
var _minimist = require('minimist'); | ||
var _minimist2 = _interopRequireDefault(_minimist); | ||
var _neon_new = require('./ops/neon_new'); | ||
@@ -32,2 +28,14 @@ | ||
var _commandLineCommands = require('command-line-commands'); | ||
var _commandLineCommands2 = _interopRequireDefault(_commandLineCommands); | ||
var _commandLineArgs = require('command-line-args'); | ||
var _commandLineArgs2 = _interopRequireDefault(_commandLineArgs); | ||
var _commandLineUsage = require('command-line-usage'); | ||
var _commandLineUsage2 = _interopRequireDefault(_commandLineUsage); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
@@ -39,47 +47,169 @@ | ||
function printUsage() { | ||
console.log(); | ||
console.log("Usage:"); | ||
console.log(); | ||
console.log(" neon new [@<scope>/]<name> [--rust|-r nightly|stable|default]"); | ||
console.log(" create a new Neon project"); | ||
console.log(); | ||
console.log(" neon build [--rust|-r nightly|stable|default] [--debug|-d]"); | ||
console.log(" rebuild the project"); | ||
console.log(); | ||
console.log(" neon version"); | ||
console.log(" print neon-cli version"); | ||
console.log(); | ||
console.log(" neon help"); | ||
console.log(" print this usage information"); | ||
console.log(); | ||
console.log("neon-cli@" + _package2.default.version + " " + _path2.default.dirname(__dirname)); | ||
function channel(value) { | ||
if (!['default', 'nightly', 'beta', 'stable'].indexOf(value) > -1) { | ||
throw new Error("Expected one of 'default', 'nightly', 'beta', or 'stable', got '" + value + "'"); | ||
} | ||
return value; | ||
} | ||
const SUBCOMMANDS = { | ||
'version': function version() { | ||
console.log(_package2.default.version); | ||
function commandUsage(command) { | ||
if (!spec[command]) { | ||
let e = new Error(); | ||
e.command = command; | ||
e.name = 'INVALID_COMMAND'; | ||
throw e; | ||
} | ||
console.error((0, _commandLineUsage2.default)(spec[command].usage)); | ||
} | ||
const spec = { | ||
null: { | ||
args: [{ name: "version", alias: "v", type: Boolean }, { name: "help", alias: "h", type: String, defaultValue: null }], | ||
usage: [{ | ||
header: "Neon", | ||
content: "Neon is a tool for building native Node.js modules with Rust." | ||
}, { | ||
header: "Synopsis", | ||
content: "$ neon [options] <command>" | ||
}, { | ||
header: "Command List", | ||
content: [{ name: "new", summary: "Create a new Neon project." }, { name: "build", summary: "(Re)build a Neon project." }, { name: "version", summary: "Display the Neon version." }, { name: "help", summary: "Display help information about Neon." }] | ||
}], | ||
action: function action(options, usage) { | ||
if (options.version && options.help === undefined) { | ||
spec.version.action.call(this, options); | ||
} else if (options.help !== undefined) { | ||
commandUsage(options.help); | ||
} else { | ||
console.error(usage); | ||
} | ||
} | ||
}, | ||
'help': function help() { | ||
printUsage(); | ||
help: { | ||
args: [{ name: "command", type: String, defaultOption: true }, { name: "help", alias: "h", type: Boolean }], | ||
usage: [{ | ||
header: "neon help", | ||
content: "Get help about a Neon command" | ||
}, { | ||
header: "Synopsis", | ||
content: "$ neon help [command]" | ||
}], | ||
action: function action(options) { | ||
if (options && options.command) { | ||
commandUsage(options.command); | ||
} else if (options && options.help) { | ||
commandUsage('help'); | ||
} else { | ||
console.error((0, _commandLineUsage2.default)(spec.null.usage)); | ||
} | ||
} | ||
}, | ||
'new': function _new() { | ||
if (this.args._.length !== 1) { | ||
printUsage(); | ||
console.log(); | ||
throw new Error(this.args._.length === 0 ? "You must specify a project name." : "Too many arguments."); | ||
new: { | ||
args: [{ name: "rust", alias: "r", type: channel, defaultValue: "default" }, { name: "name", type: String, defaultOption: true }, { name: "help", alias: "h", type: Boolean }], | ||
usage: [{ | ||
header: "neon new", | ||
content: "Create a new Neon project." | ||
}, { | ||
header: "Synopsis", | ||
content: "$ neon new [options] [@<scope>/]<name>" | ||
}, { | ||
header: "Options", | ||
optionList: [{ | ||
name: "rust", | ||
alias: "r", | ||
type: channel, | ||
description: "Rust channel (default, nightly, beta, or stable). [default: default]" | ||
}] | ||
}], | ||
action: function action(options) { | ||
if (options.help) { | ||
commandUsage('new'); | ||
return; | ||
} | ||
return (0, _neon_new2.default)(this.cwd, options.name, options.rust); | ||
} | ||
return (0, _neon_new2.default)(this.cwd, this.args._[0], this.args.rust || this.args.r || 'default'); | ||
}, | ||
'build': function build() { | ||
if (this.args._.length > 0) { | ||
printUsage(); | ||
console.log(); | ||
throw new Error("Too many arguments."); | ||
build: { | ||
args: [{ name: "debug", alias: "d", type: Boolean }, { name: "path", alias: "p", type: Boolean }, { name: "rust", alias: "r", type: channel, defaultValue: "default" }, { name: "modules", type: String, multiple: true, defaultOption: true }, { name: "node_module_version", type: Number }, { name: "help", alias: "h", type: Boolean }], | ||
usage: [{ | ||
header: "neon build", | ||
content: "(Re)build a Neon project." | ||
}, { | ||
header: "Synopsis", | ||
content: ["$ neon build [options]", "$ neon build [options] [underline]{module} ..."] | ||
}, { | ||
header: "Options", | ||
optionList: [{ | ||
name: "rust", | ||
alias: "r", | ||
type: channel, | ||
description: "Rust channel (default, nightly, beta, or stable). [default: default]" | ||
}, { | ||
name: "debug", | ||
alias: "d", | ||
type: Boolean, | ||
description: "Debug build." | ||
}, { | ||
name: "path", | ||
alias: "p", | ||
type: Boolean, | ||
description: "Specify modules by path instead of name." | ||
}] | ||
}], | ||
action: (() => { | ||
var _ref = _asyncToGenerator(function* (options) { | ||
var _this = this; | ||
if (options.help) { | ||
commandUsage('build'); | ||
return; | ||
} | ||
let modules = options.modules ? options.modules.map(function (m) { | ||
return options.path ? _path2.default.resolve(_this.cwd, m) : _path2.default.resolve(_this.cwd, 'node_modules', m); | ||
}) : [this.cwd]; | ||
let info = modules.length > 1; | ||
for (let mod of modules) { | ||
if (info) { | ||
console.log(style.info("building Neon package at " + (_path2.default.relative(this.cwd, mod) || "."))); | ||
} | ||
yield (0, _neon_build2.default)(mod, options.rust, options.debug ? 'debug' : 'release', options.node_module_version); | ||
} | ||
}); | ||
function action(_x) { | ||
return _ref.apply(this, arguments); | ||
} | ||
return action; | ||
})() | ||
}, | ||
version: { | ||
args: [{ name: "help", alias: "h", type: Boolean }], | ||
usage: [{ | ||
header: "neon version", | ||
content: "Display the Neon version." | ||
}, { | ||
header: "Synopsis", | ||
content: "$ neon version" | ||
}], | ||
action: function action(options) { | ||
if (options.help) { | ||
commandUsage('version'); | ||
return; | ||
} | ||
console.log(_package2.default.version); | ||
} | ||
return (0, _neon_build2.default)(this.cwd, this.args.rust || this.args.r || 'default', this.args.debug || this.args.d ? 'debug' : 'release', this.args.node_module_version); | ||
} | ||
}; | ||
@@ -89,4 +219,3 @@ | ||
constructor(argv, cwd) { | ||
this.command = argv[2]; | ||
this.args = (0, _minimist2.default)(argv.slice(3)); | ||
this.argv = argv.slice(2); | ||
this.cwd = cwd; | ||
@@ -96,21 +225,25 @@ } | ||
exec() { | ||
var _this = this; | ||
var _this2 = this; | ||
return _asyncToGenerator(function* () { | ||
try { | ||
if (!_this.command) { | ||
printUsage(); | ||
throw null; | ||
} | ||
if (!SUBCOMMANDS.hasOwnProperty(_this.command)) { | ||
printUsage(); | ||
console.log(); | ||
throw new Error("'" + _this.command + "' is not a neon command."); | ||
} | ||
yield SUBCOMMANDS[_this.command].call(_this); | ||
var _parseCommands = (0, _commandLineCommands2.default)([null, 'help', 'new', 'build', 'version'], _this2.argv); | ||
let command = _parseCommands.command, | ||
argv = _parseCommands.argv; | ||
yield spec[command].action.call(_this2, (0, _commandLineArgs2.default)(spec[command].args, { argv: argv }), (0, _commandLineUsage2.default)(spec[command].usage)); | ||
} catch (e) { | ||
if (e) { | ||
console.log(style.error(e.message)); | ||
spec.help.action.call(_this2); | ||
switch (e.name) { | ||
case 'INVALID_COMMAND': | ||
console.error(style.error("No manual entry for `neon " + e.command + "`")); | ||
break; | ||
default: | ||
console.error(style.error(e.message)); | ||
break; | ||
} | ||
throw e; | ||
} | ||
@@ -117,0 +250,0 @@ })(); |
@@ -10,7 +10,7 @@ 'use strict'; | ||
let main = (() => { | ||
var _ref3 = _asyncToGenerator(function* (name, configuration, target) { | ||
var _ref3 = _asyncToGenerator(function* (root, name, configuration, target) { | ||
let pp = process.platform; | ||
let output_directory = target ? _path2.default.resolve('native', 'target', target, configuration) : _path2.default.resolve('native', 'target', configuration); | ||
let output_directory = target ? _path2.default.resolve(root, 'native', 'target', target, configuration) : _path2.default.resolve(root, 'native', 'target', configuration); | ||
let dylib = _path2.default.resolve(output_directory, LIB_PREFIX[pp] + name + LIB_SUFFIX[pp]); | ||
let index = _path2.default.resolve('native', 'index.node'); | ||
let index = _path2.default.resolve(root, 'native', 'index.node'); | ||
@@ -23,3 +23,3 @@ console.log(style.info("generating native" + _path2.default.sep + "index.node")); | ||
return function main(_x, _x2, _x3) { | ||
return function main(_x, _x2, _x3, _x4) { | ||
return _ref3.apply(this, arguments); | ||
@@ -90,3 +90,3 @@ }; | ||
function cargo(toolchain, configuration, nodeModuleVersion, target) { | ||
function cargo(root, toolchain, configuration, nodeModuleVersion, target) { | ||
let macos = process.platform === 'darwin'; | ||
@@ -113,9 +113,9 @@ | ||
return (0, _child_process.spawn)(command, args, { cwd: 'native', stdio: 'inherit', env: env }); | ||
return (0, _child_process.spawn)(command, args, { cwd: _path2.default.resolve(root, 'native'), stdio: 'inherit', env: env }); | ||
} | ||
exports.default = (() => { | ||
var _ref4 = _asyncToGenerator(function* (pwd, toolchain, configuration, nodeModuleVersion) { | ||
var _ref4 = _asyncToGenerator(function* (root, toolchain, configuration, nodeModuleVersion) { | ||
// 1. Read the Cargo metadata. | ||
let metadata = _toml2.default.parse((yield (0, _fs.readFile)(_path2.default.resolve('native', 'Cargo.toml'), 'utf8'))); | ||
let metadata = _toml2.default.parse((yield (0, _fs.readFile)(_path2.default.resolve(root, 'native', 'Cargo.toml'), 'utf8'))); | ||
@@ -131,3 +131,3 @@ if (!metadata.lib.name) { | ||
// 2. Build the binary. | ||
if ((yield cargo(toolchain, configuration, nodeModuleVersion, target)) !== 0) { | ||
if ((yield cargo(root, toolchain, configuration, nodeModuleVersion, target)) !== 0) { | ||
throw new Error("cargo build failed"); | ||
@@ -137,6 +137,6 @@ } | ||
// 3. Copy the dylib into the main index.node file. | ||
yield main(metadata.lib.name, configuration, target); | ||
yield main(root, metadata.lib.name, configuration, target); | ||
}); | ||
function neon_build(_x4, _x5, _x6, _x7) { | ||
function neon_build(_x5, _x6, _x7, _x8) { | ||
return _ref4.apply(this, arguments); | ||
@@ -143,0 +143,0 @@ } |
{ | ||
"name": "neon-cli", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"description": "Build and load native Rust/Neon modules.", | ||
@@ -17,2 +17,5 @@ "author": "Dave Herman <dherman@mozilla.com>", | ||
"chalk": "^1.1.1", | ||
"command-line-args": "^4.0.2", | ||
"command-line-commands": "^2.0.0", | ||
"command-line-usage": "^4.0.0", | ||
"fs-extra": "^0.26.3", | ||
@@ -23,3 +26,2 @@ "git-config": "0.0.7", | ||
"inquirer": "^0.11.0", | ||
"minimist": "^1.2.0", | ||
"rsvp": "^3.1.0", | ||
@@ -26,0 +28,0 @@ "semver": "^5.1.0", |
@@ -0,1 +1,5 @@ | ||
# Version 0.1.14 | ||
* Clean up the CLI and allow `neon build` to optionally take module names (#48). | ||
# Version 0.1.13 | ||
@@ -2,0 +6,0 @@ |
232
src/cli.js
import path from 'path'; | ||
import metadata from '../package.json'; | ||
import minimist from 'minimist'; | ||
import neon_new from './ops/neon_new'; | ||
import neon_build from './ops/neon_build'; | ||
import * as style from './ops/style'; | ||
import parseCommands from 'command-line-commands'; | ||
import parseArgs from 'command-line-args'; | ||
import parseUsage from 'command-line-usage'; | ||
function printUsage() { | ||
console.log(); | ||
console.log("Usage:"); | ||
console.log(); | ||
console.log(" neon new [@<scope>/]<name> [--rust|-r nightly|stable|default]"); | ||
console.log(" create a new Neon project"); | ||
console.log(); | ||
console.log(" neon build [--rust|-r nightly|stable|default] [--debug|-d]"); | ||
console.log(" rebuild the project"); | ||
console.log(); | ||
console.log(" neon version"); | ||
console.log(" print neon-cli version"); | ||
console.log(); | ||
console.log(" neon help"); | ||
console.log(" print this usage information"); | ||
console.log(); | ||
console.log("neon-cli@" + metadata.version + " " + path.dirname(__dirname)); | ||
function channel(value) { | ||
if (!['default', 'nightly', 'beta', 'stable'].indexOf(value) > -1) { | ||
throw new Error("Expected one of 'default', 'nightly', 'beta', or 'stable', got '" + value + "'"); | ||
} | ||
return value; | ||
} | ||
const SUBCOMMANDS = { | ||
'version': function() { | ||
console.log(metadata.version); | ||
function commandUsage(command) { | ||
if (!spec[command]) { | ||
let e = new Error(); | ||
e.command = command; | ||
e.name = 'INVALID_COMMAND'; | ||
throw e; | ||
} | ||
console.error(parseUsage(spec[command].usage)); | ||
} | ||
const spec = { | ||
null: { | ||
args: [{ name: "version", alias: "v", type: Boolean }, | ||
{ name: "help", alias: "h", type: String, defaultValue: null }], | ||
usage: [{ | ||
header: "Neon", | ||
content: "Neon is a tool for building native Node.js modules with Rust." | ||
}, { | ||
header: "Synopsis", | ||
content: "$ neon [options] <command>" | ||
}, { | ||
header: "Command List", | ||
content: [{ name: "new", summary: "Create a new Neon project." }, | ||
{ name: "build", summary: "(Re)build a Neon project." }, | ||
{ name: "version", summary: "Display the Neon version." }, | ||
{ name: "help", summary: "Display help information about Neon." }] | ||
}], | ||
action: function(options, usage) { | ||
if (options.version && options.help === undefined) { | ||
spec.version.action.call(this, options); | ||
} else if (options.help !== undefined) { | ||
commandUsage(options.help); | ||
} else { | ||
console.error(usage); | ||
} | ||
} | ||
}, | ||
'help': function() { | ||
printUsage(); | ||
help: { | ||
args: [{ name: "command", type: String, defaultOption: true }, | ||
{ name: "help", alias: "h", type: Boolean }], | ||
usage: [{ | ||
header: "neon help", | ||
content: "Get help about a Neon command" | ||
}, { | ||
header: "Synopsis", | ||
content: "$ neon help [command]" | ||
}], | ||
action: function(options) { | ||
if (options && options.command) { | ||
commandUsage(options.command); | ||
} else if (options && options.help) { | ||
commandUsage('help'); | ||
} else { | ||
console.error(parseUsage(spec.null.usage)); | ||
} | ||
} | ||
}, | ||
'new': function() { | ||
if (this.args._.length !== 1) { | ||
printUsage(); | ||
console.log(); | ||
throw new Error(this.args._.length === 0 ? "You must specify a project name." : "Too many arguments."); | ||
new: { | ||
args: [{ name: "rust", alias: "r", type: channel, defaultValue: "default" }, | ||
{ name: "name", type: String, defaultOption: true }, | ||
{ name: "help", alias: "h", type: Boolean }], | ||
usage: [{ | ||
header: "neon new", | ||
content: "Create a new Neon project." | ||
}, { | ||
header: "Synopsis", | ||
content: "$ neon new [options] [@<scope>/]<name>" | ||
}, { | ||
header: "Options", | ||
optionList: [{ | ||
name: "rust", | ||
alias: "r", | ||
type: channel, | ||
description: "Rust channel (default, nightly, beta, or stable). [default: default]" | ||
}] | ||
}], | ||
action: function(options) { | ||
if (options.help) { | ||
commandUsage('new'); | ||
return; | ||
} | ||
return neon_new(this.cwd, options.name, options.rust); | ||
} | ||
return neon_new(this.cwd, this.args._[0], this.args.rust || this.args.r || 'default'); | ||
}, | ||
'build': function() { | ||
if (this.args._.length > 0) { | ||
printUsage(); | ||
console.log(); | ||
throw new Error("Too many arguments."); | ||
build: { | ||
args: [{ name: "debug", alias: "d", type: Boolean }, | ||
{ name: "path", alias: "p", type: Boolean }, | ||
{ name: "rust", alias: "r", type: channel, defaultValue: "default" }, | ||
{ name: "modules", type: String, multiple: true, defaultOption: true }, | ||
{ name: "node_module_version", type: Number }, | ||
{ name: "help", alias: "h", type: Boolean }], | ||
usage: [{ | ||
header: "neon build", | ||
content: "(Re)build a Neon project." | ||
}, { | ||
header: "Synopsis", | ||
content: ["$ neon build [options]", | ||
"$ neon build [options] [underline]{module} ..."] | ||
}, { | ||
header: "Options", | ||
optionList: [{ | ||
name: "rust", | ||
alias: "r", | ||
type: channel, | ||
description: "Rust channel (default, nightly, beta, or stable). [default: default]" | ||
}, { | ||
name: "debug", | ||
alias: "d", | ||
type: Boolean, | ||
description: "Debug build." | ||
}, { | ||
name: "path", | ||
alias: "p", | ||
type: Boolean, | ||
description: "Specify modules by path instead of name." | ||
}] | ||
}], | ||
action: async function(options) { | ||
if (options.help) { | ||
commandUsage('build'); | ||
return; | ||
} | ||
let modules = options.modules | ||
? options.modules.map(m => options.path ? path.resolve(this.cwd, m) | ||
: path.resolve(this.cwd, 'node_modules', m)) | ||
: [this.cwd]; | ||
let info = modules.length > 1; | ||
for (let mod of modules) { | ||
if (info) { | ||
console.log(style.info("building Neon package at " + (path.relative(this.cwd, mod) || "."))); | ||
} | ||
await neon_build(mod, options.rust, options.debug ? 'debug' : 'release', options.node_module_version); | ||
} | ||
} | ||
return neon_build(this.cwd, | ||
this.args.rust || this.args.r || 'default', | ||
this.args.debug || this.args.d ? 'debug' : 'release', | ||
this.args.node_module_version); | ||
}, | ||
version: { | ||
args: [{ name: "help", alias: "h", type: Boolean }], | ||
usage: [{ | ||
header: "neon version", | ||
content: "Display the Neon version." | ||
}, { | ||
header: "Synopsis", | ||
content: "$ neon version" | ||
}], | ||
action: function(options) { | ||
if (options.help) { | ||
commandUsage('version'); | ||
return; | ||
} | ||
console.log(metadata.version); | ||
} | ||
} | ||
}; | ||
@@ -60,4 +185,3 @@ | ||
constructor(argv, cwd) { | ||
this.command = argv[2]; | ||
this.args = minimist(argv.slice(3)); | ||
this.argv = argv.slice(2); | ||
this.cwd = cwd; | ||
@@ -68,19 +192,21 @@ } | ||
try { | ||
if (!this.command) { | ||
printUsage(); | ||
throw null; | ||
} | ||
if (!SUBCOMMANDS.hasOwnProperty(this.command)) { | ||
printUsage(); | ||
console.log(); | ||
throw new Error("'" + this.command + "' is not a neon command."); | ||
} | ||
await SUBCOMMANDS[this.command].call(this); | ||
let { command, argv } = parseCommands([ null, 'help', 'new', 'build', 'version' ], this.argv); | ||
await spec[command].action.call(this, | ||
parseArgs(spec[command].args, { argv }), | ||
parseUsage(spec[command].usage)); | ||
} catch (e) { | ||
if (e) { | ||
console.log(style.error(e.message)); | ||
spec.help.action.call(this); | ||
switch (e.name) { | ||
case 'INVALID_COMMAND': | ||
console.error(style.error("No manual entry for `neon " + e.command + "`")); | ||
break; | ||
default: | ||
console.error(style.error(e.message)); | ||
break; | ||
} | ||
throw e; | ||
} | ||
} | ||
} |
@@ -39,3 +39,3 @@ import { remove, copy, readFile } from '../async/fs'; | ||
function cargo(toolchain, configuration, nodeModuleVersion, target) { | ||
function cargo(root, toolchain, configuration, nodeModuleVersion, target) { | ||
let macos = process.platform === 'darwin'; | ||
@@ -61,12 +61,12 @@ | ||
return spawn(command, args, { cwd: 'native', stdio: 'inherit', env: env }); | ||
return spawn(command, args, { cwd: path.resolve(root, 'native'), stdio: 'inherit', env: env }); | ||
} | ||
async function main(name, configuration, target) { | ||
async function main(root, name, configuration, target) { | ||
let pp = process.platform; | ||
let output_directory = target ? | ||
path.resolve('native', 'target', target, configuration) : | ||
path.resolve('native', 'target', configuration); | ||
path.resolve(root, 'native', 'target', target, configuration) : | ||
path.resolve(root, 'native', 'target', configuration); | ||
let dylib = path.resolve(output_directory, LIB_PREFIX[pp] + name + LIB_SUFFIX[pp]); | ||
let index = path.resolve('native', 'index.node'); | ||
let index = path.resolve(root, 'native', 'index.node'); | ||
@@ -79,5 +79,5 @@ console.log(style.info("generating native" + path.sep + "index.node")); | ||
export default async function neon_build(pwd, toolchain, configuration, nodeModuleVersion) { | ||
export default async function neon_build(root, toolchain, configuration, nodeModuleVersion) { | ||
// 1. Read the Cargo metadata. | ||
let metadata = TOML.parse(await readFile(path.resolve('native', 'Cargo.toml'), 'utf8')); | ||
let metadata = TOML.parse(await readFile(path.resolve(root, 'native', 'Cargo.toml'), 'utf8')); | ||
@@ -93,3 +93,3 @@ if (!metadata.lib.name) { | ||
// 2. Build the binary. | ||
if ((await cargo(toolchain, configuration, nodeModuleVersion, target)) !== 0) { | ||
if ((await cargo(root, toolchain, configuration, nodeModuleVersion, target)) !== 0) { | ||
throw new Error("cargo build failed"); | ||
@@ -99,3 +99,3 @@ } | ||
// 3. Copy the dylib into the main index.node file. | ||
await main(metadata.lib.name, configuration, target); | ||
await main(root, metadata.lib.name, configuration, target); | ||
} |
import { setup } from '../support/acceptance'; | ||
describe('neon help', function() { | ||
setup(); | ||
function describeHelp(cmd, should, test, args) { | ||
describe(cmd, function() { | ||
setup('stderr'); | ||
it('should print neon usage', function(done) { | ||
this.spawn(['help']) | ||
.wait('Usage:') | ||
.wait('neon new') | ||
.wait('neon version') | ||
.wait('neon help') | ||
.run(err => { | ||
if (err) throw err; | ||
done(); | ||
}); | ||
it(should, function(done) { | ||
test(this.spawn(args), done); | ||
}); | ||
}); | ||
}); | ||
} | ||
function testHelp(proc, done) { | ||
return proc | ||
.wait("Neon") | ||
.wait("native Node.js modules with Rust") | ||
.wait("Synopsis") | ||
.wait("$ neon [options] <command>") | ||
.wait("Command List") | ||
.wait("new") | ||
.wait("build") | ||
.wait("version") | ||
.wait("help") | ||
.run(err => { | ||
if (err) throw err; | ||
done(); | ||
}); | ||
} | ||
describeHelp("neon help", "should print neon usage", testHelp, ['help']); | ||
describeHelp("neon --help", "should print neon usage", testHelp, ['--help']); | ||
describeHelp("neon -h", "should print neon usage", testHelp, ['-h']); | ||
function testHelpVersion(proc, done) { | ||
return proc | ||
.wait("neon version") | ||
.wait("Display the Neon version.") | ||
.wait("Synopsis") | ||
.wait("$ neon version") | ||
.run(err => { | ||
if (err) throw err; | ||
done(); | ||
}); | ||
} | ||
describeHelp("neon help version", "should print `neon version` usage", testHelpVersion, ['help', 'version']); | ||
describeHelp("neon version --help", "should print `neon version` usage", testHelpVersion, ['version', '--help']); | ||
describeHelp("neon version -h", "should print `neon version` usage", testHelpVersion, ['version', '-h']); | ||
describeHelp("neon --help version", "should print `neon version` usage", testHelpVersion, ['--help', 'version']); | ||
describeHelp("neon -h version", "should print `neon version` usage", testHelpVersion, ['-h', 'version']); | ||
function testHelpNew(proc, done) { | ||
return proc | ||
.wait("neon new") | ||
.wait("Create a new Neon project") | ||
.wait("Synopsis") | ||
.wait("$ neon new [options] [@<scope>/]<name>") | ||
.wait("Options") | ||
.wait("-r, --rust") | ||
.run(err => { | ||
if (err) throw err; | ||
done(); | ||
}); | ||
} | ||
describeHelp("neon help new", "should print `neon new` usage", testHelpNew, ['help', 'new']); | ||
describeHelp("neon new --help", "should print `neon new` usage", testHelpNew, ['new', '--help']); | ||
describeHelp("neon new -h", "should print `neon new` usage", testHelpNew, ['new', '-h']); | ||
describeHelp("neon --help new", "should print `neon new` usage", testHelpNew, ['--help', 'new']); | ||
describeHelp("neon -h new", "should print `neon new` usage", testHelpNew, ['-h', 'new']); | ||
function testHelpBuild(proc, done) { | ||
return proc | ||
.wait("neon build") | ||
.wait("(Re)build a Neon project") | ||
.wait("Synopsis") | ||
.wait("$ neon build [options]") | ||
.wait("$ neon build [options] module ...") | ||
.wait("Options") | ||
.wait("-r, --rust") | ||
.wait("-d, --debug") | ||
.wait("-p, --path") | ||
.run(err => { | ||
if (err) throw err; | ||
done(); | ||
}); | ||
} | ||
describeHelp("neon help build", "should print `neon build` usage", testHelpBuild, ['help', 'build']); | ||
describeHelp("neon build --help", "should print `neon build` usage", testHelpBuild, ['build', '--help']); | ||
describeHelp("neon build -h", "should print `neon build` usage", testHelpBuild, ['build', '-h']); | ||
describeHelp("neon --help build", "should print `neon build` usage", testHelpBuild, ['--help', 'build']); | ||
describeHelp("neon -h build", "should print `neon build` usage", testHelpBuild, ['-h', 'build']); | ||
function testHelpHelp(proc, done) { | ||
return proc | ||
.wait("neon help") | ||
.wait("Get help about a Neon command") | ||
.wait("Synopsis") | ||
.wait("$ neon help [command]") | ||
.run(err => { | ||
if (err) throw err; | ||
done(); | ||
}); | ||
} | ||
describeHelp("neon help help", "should print `neon help` usage", testHelpHelp, ['help', 'help']); | ||
describeHelp("neon help --help", "should print `neon help` usage", testHelpHelp, ['help', '--help']); | ||
describeHelp("neon help -h", "should print `neon help` usage", testHelpHelp, ['help', '-h']); | ||
describeHelp("neon --help help", "should print `neon help` usage", testHelpHelp, ['--help', 'help']); | ||
describeHelp("neon -h help", "should print `neon help` usage", testHelpHelp, ['-h', 'help']); |
@@ -8,3 +8,3 @@ import tmp from 'tmp'; | ||
export function setup() { | ||
export function setup(stream = 'all') { | ||
let tmpobj; | ||
@@ -16,3 +16,3 @@ | ||
this.cwd = tmpobj.name; | ||
this.spawn = (args) => spawn(NODE, [NEON].concat(args), { cwd: this.cwd }); | ||
this.spawn = (args) => spawn(NODE, [NEON].concat(args), { cwd: this.cwd, stream, stripColors: true }); | ||
}); | ||
@@ -19,0 +19,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55697
1208
15
+ Addedcommand-line-args@^4.0.2
+ Addedcommand-line-commands@^2.0.0
+ Addedcommand-line-usage@^4.0.0
+ Addedansi-escape-sequences@4.1.0(transitive)
+ Addedarray-back@1.0.42.0.03.1.0(transitive)
+ Addedcommand-line-args@4.0.7(transitive)
+ Addedcommand-line-commands@2.0.1(transitive)
+ Addedcommand-line-usage@4.1.0(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addedfind-replace@1.0.3(transitive)
+ Addedlodash.padend@4.6.1(transitive)
+ Addedreduce-flatten@1.0.1(transitive)
+ Addedtable-layout@0.4.5(transitive)
+ Addedtest-value@2.1.0(transitive)
+ Addedtypical@2.6.1(transitive)
+ Addedwordwrapjs@3.0.0(transitive)
- Removedminimist@^1.2.0