Skip to content

Commit 780a197

Browse files
committed
refactoring
1 parent 1bbbe05 commit 780a197

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"package-nochrome": "npm run package-prepare && zip -rq ../package.zip .",
55
"package-prepare": "npm run lint && npm run babel && cp -r package.json dist && cd dist && PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm install --production",
66
"babel": "rm -rf dist && mkdir dist && ./node_modules/.bin/babel src --out-dir dist",
7-
"local": "npm run babel && cp -r node_modules dist && node dist/local.js",
7+
"local": "npm run babel && cp -r node_modules dist && node dist/starter-kit/local.js",
88
"lint": "./node_modules/.bin/eslint src"
99
},
1010
"dependencies": {

src/index.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
const puppeteer = require('puppeteer');
2-
const config = require('./config');
3-
const util = require('./util');
2+
const config = require('./starter-kit/config');
3+
const util = require('./starter-kit/util');
44

55
exports.handler = async (event, context, callback) => {
66
exports.run({
77
headless: true,
8-
chromePath: await util.setupChrome(),
8+
executablePath: await util.setupChrome(),
9+
args: config.launchOptionForLambda,
10+
dumpio: !!util.DEBUG,
911
}).then(
1012
(result) => callback(null, result)
1113
).catch(
1214
(err) => callback(err)
1315
);
1416
};
1517

16-
exports.run = async (option) => {
17-
const browser = await puppeteer.launch({
18-
headless: option.headless,
19-
executablePath: option.chromePath,
20-
slowMo: option.slowMoMs,
21-
args: config.launchOptionForLambda,
22-
dumpio: !!util.DEBUG,
23-
});
18+
exports.run = async (launchOption) => {
19+
const browser = await puppeteer.launch(launchOption);
2420

2521
util.debugLog(`Chrome launched, version ${await browser.version()}`);
2622

File renamed without changes.

src/local.js renamed to src/starter-kit/local.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const index = require('./index');
1+
const index = require('../index');
22

33
index.run({
44
headless: false,
5-
slowMoMs: 250,
5+
slowMo: 250,
6+
dumpio: !!util.DEBUG,
67
// use chrome installed by puppeteer
78
}).then(
89
(result) => console.log(result)
File renamed without changes.

0 commit comments

Comments
 (0)