2016-12-11 14:36:58 -08:00
|
|
|
'use strict';
|
|
|
|
const Path = require('path');
|
|
|
|
|
|
|
|
const { test } = require('tap');
|
|
|
|
|
|
|
|
const startCLI = require('./start-cli');
|
|
|
|
|
|
|
|
test('list scripts', (t) => {
|
2017-04-04 09:47:43 -07:00
|
|
|
const script = Path.join('examples', 'three-lines.js');
|
2016-12-11 14:36:58 -08:00
|
|
|
const cli = startCLI([script]);
|
|
|
|
|
|
|
|
function onFatal(error) {
|
|
|
|
cli.quit();
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
|
2017-04-04 09:47:43 -07:00
|
|
|
return cli.waitForInitialBreak()
|
2016-12-11 14:36:58 -08:00
|
|
|
.then(() => cli.waitForPrompt())
|
|
|
|
.then(() => cli.command('scripts'))
|
|
|
|
.then(() => {
|
|
|
|
t.match(
|
|
|
|
cli.output,
|
2017-04-04 09:47:43 -07:00
|
|
|
/^\* \d+: examples(?:\/|\\)three-lines\.js/,
|
2016-12-11 14:36:58 -08:00
|
|
|
'lists the user script');
|
|
|
|
t.notMatch(
|
|
|
|
cli.output,
|
2019-06-03 10:05:10 +02:00
|
|
|
/\d+: buffer\.js <native>/,
|
2016-12-11 14:36:58 -08:00
|
|
|
'omits node-internal scripts');
|
|
|
|
})
|
|
|
|
.then(() => cli.command('scripts(true)'))
|
|
|
|
.then(() => {
|
|
|
|
t.match(
|
|
|
|
cli.output,
|
2017-04-04 09:47:43 -07:00
|
|
|
/\* \d+: examples(?:\/|\\)three-lines\.js/,
|
2016-12-11 14:36:58 -08:00
|
|
|
'lists the user script');
|
|
|
|
t.match(
|
|
|
|
cli.output,
|
2019-06-03 10:05:10 +02:00
|
|
|
/\d+: buffer\.js <native>/,
|
2016-12-11 14:36:58 -08:00
|
|
|
'includes node-internal scripts');
|
|
|
|
})
|
|
|
|
.then(() => cli.quit())
|
|
|
|
.then(null, onFatal);
|
|
|
|
});
|