-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
55 lines (50 loc) · 1.34 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const inquirer = require('inquirer');
const puppeteer = require('puppeteer');
const path = require('path');
const questions = [
{
type: 'input',
name: 'name',
message: 'Qual seu email?',
},
{
type: 'password',
name: 'password',
message: 'Qual seu password?',
},
];
/* ######### PKG DEPLOYMENT CONFIGURATION ########## */
const isPkg = typeof process.pkg !== 'undefined';
// mac path replace
let chromiumExecutablePath = isPkg
? puppeteer
.executablePath()
.replace(
/^.*?\/node_modules\/puppeteer\/\.local-chromium/,
path.join(path.dirname(process.execPath), 'chromium')
)
: puppeteer.executablePath();
console.log(process.platform);
// check win32
if (process.platform == 'win32') {
chromiumExecutablePath = isPkg
? puppeteer
.executablePath()
.replace(
/^.*?\\node_modules\\puppeteer\\\.local-chromium/,
path.join(path.dirname(process.execPath), 'chromium')
)
: puppeteer.executablePath();
}
/* ######### PKG DEPLOYMENT CONFIGURATION ########## */
const utils = {
getUserPass: async () => {
const resp = await inquirer.prompt(questions).then(answers => {
console.log(`Olá ${answers.name}! Iniciando processo`);
return answers;
});
return resp;
},
getPath: chromiumExecutablePath,
};
module.exports = utils;