Igor Klopov
8 years ago
committed by
Leo Lamprecht
2 changed files with 52 additions and 1 deletions
@ -0,0 +1,50 @@ |
|||||
|
const path = require('path') |
||||
|
const crossSpawn = require('cross-spawn') |
||||
|
const test = require('ava') |
||||
|
|
||||
|
test.serial('make binary', async t => { |
||||
|
if (!process.env.CI) return // eslint-disable-line curly
|
||||
|
const result = await spawn('npm', ['run', 'pkg']) |
||||
|
t.is(result.code, 0) |
||||
|
}) |
||||
|
|
||||
|
const binary = { |
||||
|
darwin: 'now-macos', |
||||
|
linux: 'now-linux', |
||||
|
win32: 'now-win.exe' |
||||
|
}[process.platform] |
||||
|
|
||||
|
const binaryPath = path.resolve(__dirname, '../packed/' + binary) |
||||
|
const deployHelpMessage = '𝚫 now [options] <command | path>' |
||||
|
|
||||
|
test.serial('packed "now help" prints deploy help message', async t => { |
||||
|
if (!process.env.CI) return // eslint-disable-line curly
|
||||
|
const result = await spawn(binaryPath, ['help']) |
||||
|
|
||||
|
t.is(result.code, 0) |
||||
|
const stdout = result.stdout.split('\n') |
||||
|
t.true(stdout.length > 1) |
||||
|
t.true(stdout[1].includes(deployHelpMessage)) |
||||
|
}) |
||||
|
|
||||
|
function spawn(command, args) { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
const child = crossSpawn.spawn(command, args) |
||||
|
|
||||
|
let stdout = '' |
||||
|
child.stdout.on('data', data => { |
||||
|
stdout += data |
||||
|
}) |
||||
|
|
||||
|
child.on('error', err => { |
||||
|
reject(err) |
||||
|
}) |
||||
|
|
||||
|
child.on('close', code => { |
||||
|
resolve({ |
||||
|
code, |
||||
|
stdout |
||||
|
}) |
||||
|
}) |
||||
|
}) |
||||
|
} |
Loading…
Reference in new issue