-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebship-init.js
executable file
·75 lines (60 loc) · 1.81 KB
/
webship-init.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env node
'use strict';
const fs = require('fs');
var insidProject = false;
var basePath = '';
var projectPath = '';
const currentPath = process.argv[1].split("node_modules");
basePath = currentPath[0].substring(0, currentPath[0].lastIndexOf("/")) + '/';
if (currentPath.length > 1) {
projectPath = basePath + "node_modules/webship-js/";
}
else {
projectPath = basePath;
}
/**
* -----------------------------------------------------
* Parse arguments
* -----------------------------------------------------
*/
const { ArgumentParser } = require('argparse');
const { version } = require('./package.json');
const parser = new ArgumentParser({
description: 'Argparse example'
});
parser.add_argument('-ci', '--continuous_integration',
{
help: 'Add your CI services (circleci, github, gitlab, bitbucket), By default: -ci circleci',
default: 'circleci',
});
parser.add_argument('-b', '--browser',
{
help: 'Add your Browser (chrome, firefox), By default: -b chrome',
default: 'chrome',
});
parser.add_argument('-os', '--operating_system',
{
help: 'Add your Operating System (linux, mac, windows), By default: -os linux',
default: 'linux',
});
var argsParse = parser.parse_args();
/**
* -----------------------------------------------------
*/
/**
* Generate the appropriate nightwatch.conf.js
*
* Generate nightwatch testing configs according to the used CI
* service, operating system, and browser.
*/
fs.unlink(projectPath + 'nightwatch.conf.js', (err) => {
if (err) {
throw err;
}
});
const confTemplate = projectPath + 'assets/config_templates/' + argsParse.continuous_integration + '-' + argsParse.operating_system + '-' + argsParse.browser + '.conf.js';
fs.copyFile(confTemplate, projectPath + 'nightwatch.conf.js', (err) => {
if (err) {
throw err;
}
});