forked from danielsogl/awesome-cordova-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci-tests.js
65 lines (54 loc) · 1.73 KB
/
ci-tests.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
const exec = require('child-process-promise').exec;
let diff;
exec(`git branch | grep \\* | cut -d ' ' -f2`)
.then(output => {
if (output.stderr) {
return Promise.reject(output.stderr);
}
const branch = output.stdout.trim();
if (branch !== 'master') {
console.log('Merging master branch in ...');
// not on master branch
// let's test the changes that were made
return exec(`git merge origin master`);
}
})
.then((output) => {
if (output && output.stderr) {
return Promise.reject(output.stderr);
}
console.log('Checking for differences ...');
return exec(`git diff --name-status origin master`)
})
.then((output) => {
if (output && output.stderr) {
return Promise.reject(output.stderr);
}
diff = output.stdout;
diff = diff.replace(/A\s+/g, '');
diff = diff.match(/src\/@ionic-native\/plugins\/([a-zA-Z0-9\-]+)\/index\.ts/g);
if (!diff) process.exit();
console.log(`${ diff.length } plugins were modified. We will now build them to verify they still work.`);
return exec('npm run build:core --silent');
})
.then((output) => {
if (output && output.stderr) {
return Promise.reject(output.stderr);
}
console.log('Built core library successfully ...');
console.log('Building plugins ...');
diff = diff.map(text => text.replace('src/@ionic-native/plugins/', '').replace('/index.ts', ''));
return exec(`npm run build:modules ${diff.join(' ')} --silent`);
})
.then((output) => {
if (output && output.stderr) {
console.log(output.stderr);
process.exit(1);
}
console.log(output.stdout);
process.exit();
})
.catch(e => {
console.log(e.message || e);
process.exit(1);
});