Add option --open/-o to open the result in your default browser. (#3493)
https://github.com/sitespeedio/sitespeed.io/issues/3492
This commit is contained in:
parent
af148d9b75
commit
e452fb532d
|
|
@ -7,6 +7,8 @@
|
|||
const fs = require('fs');
|
||||
const cli = require('../lib/cli/cli');
|
||||
const sitespeed = require('../lib/sitespeed');
|
||||
const { execSync } = require('child_process');
|
||||
const os = require('os');
|
||||
|
||||
async function run(options) {
|
||||
process.exitCode = 1;
|
||||
|
|
@ -20,6 +22,10 @@ async function run(options) {
|
|||
fs.writeFileSync('result.json', JSON.stringify(result));
|
||||
}
|
||||
|
||||
if ((options.open || options.o) && os.platform() === 'darwin') {
|
||||
execSync('open ' + result.localPath + '/index.html');
|
||||
}
|
||||
|
||||
if (
|
||||
parsed.options.budget &&
|
||||
Object.keys(result.budgetResult.failing).length > 0
|
||||
|
|
|
|||
|
|
@ -1455,6 +1455,10 @@ module.exports.parseCommandLine = function parseCommandLine() {
|
|||
.option('name', {
|
||||
describe: 'Give your test a name.'
|
||||
})
|
||||
.option('open', {
|
||||
alias: 'o',
|
||||
describe: 'Open your test result in your default browser (Mac OS only).'
|
||||
})
|
||||
.option('slug', {
|
||||
describe:
|
||||
'Give your test a slug. The slug is used when you send the metrics to your data storage to identify the test and the folder of the tests. The max length of the slug is 200 characters and it can only contain a-z A-Z 0-9 and -_ characters.'
|
||||
|
|
|
|||
|
|
@ -156,12 +156,14 @@ module.exports = {
|
|||
if (options.summary && options.summary.out) {
|
||||
console.log(options.summary.out); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
return {
|
||||
errors,
|
||||
budgetResult,
|
||||
resultUrl: resultUrls.hasBaseUrl()
|
||||
? resultUrls.reportSummaryUrl() + '/index.html'
|
||||
: ''
|
||||
: '',
|
||||
localPath: storageManager.getBaseDir()
|
||||
};
|
||||
} catch (err) {
|
||||
log.error(err);
|
||||
|
|
|
|||
Loading…
Reference in New Issue