Add cli with flags. URL now customizable
This commit is contained in:
Родитель
5a8849d65e
Коммит
10e5a9368a
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var chalk = require('chalk');
|
||||
var meow = require('meow');
|
||||
var lighthouse = require('./');
|
||||
|
||||
var cli = meow({
|
||||
pkg: './package.json',
|
||||
help: [
|
||||
'Options',
|
||||
' --help Show this help',
|
||||
' --version Current version of package',
|
||||
'',
|
||||
'Usage',
|
||||
' lighthouse [url]'
|
||||
]
|
||||
})
|
||||
|
||||
lighthouse({
|
||||
url: cli.input[0],
|
||||
flags: cli.flags
|
||||
});
|
5
index.js
5
index.js
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
const url = 'https://voice-memos.appspot.com';
|
||||
const defaultUrl = 'https://voice-memos.appspot.com';
|
||||
const ChromeProtocol = require('./helpers/browser/driver');
|
||||
|
||||
const Auditor = require('./auditor');
|
||||
|
@ -46,6 +46,8 @@ const audits = [
|
|||
require('./audits/manifest/start-url')
|
||||
];
|
||||
|
||||
module.exports = function(opts) {
|
||||
var url = opts.url || defaultUrl;
|
||||
gatherer
|
||||
.gather(gatherers, {url, driver})
|
||||
.then(artifacts => auditor.audit(artifacts, audits))
|
||||
|
@ -56,3 +58,4 @@ gatherer
|
|||
console.log(err.stack);
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"lighthouse": "cli.js"
|
||||
},
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
|
@ -27,10 +30,12 @@
|
|||
},
|
||||
"homepage": "https://github.com/googlechrome/big-rig#readme",
|
||||
"dependencies": {
|
||||
"chalk": "^1.1.1",
|
||||
"chrome-devtools-frontend": "1.0.381789",
|
||||
"chrome-remote-interface": "^0.11.0",
|
||||
"devtools-timeline-model": "1.0.16",
|
||||
"file": "^0.2.2",
|
||||
"meow": "^3.7.0",
|
||||
"traceviewer": "^1.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Загрузка…
Ссылка в новой задаче