-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatcher.js
executable file
·41 lines (31 loc) · 1.03 KB
/
watcher.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
'use strict';
let inquirer = require('inquirer');
let fs = require('fs');
let questions = require('./questions');
let nodemon = require('nodemon');
function validateUrl(url){
}
function validateUsername(username){
}
function validateCliPath(path){
if(!fs.existsSync(path)){
throw Error(`CLI not found on specified path: ${path}`)
}
}
function validateJenkinsfilePath(path){
if(!fs.existsSync(path)){
throw Error(`Jenkinsfile not found on specified path: ${path}`)
}
}
inquirer.prompt(questions.spec).then(answers => {
fs.writeFileSync(`${__dirname}/answers.json`, JSON.stringify(answers), 'utf8');
validateUrl(answers.jenkins_url);
validateUsername(answers.username);
validateJenkinsfilePath(answers.jenkinsfile_path);
validateCliPath(answers.cli_path);
nodemon(`-C ${__dirname}/index.js -w ${answers.jenkinsfile_path}`);
console.log(`>>> Watching: ${answers.jenkinsfile_path}`);
nodemon.on('restart', function (files) {
console.log(`>>> Caught restart event`);
});
});