Skip to content

Commit 7714360

Browse files
committed
Let process exit itself
1 parent 678c231 commit 7714360

File tree

3 files changed

+14
-32
lines changed

3 files changed

+14
-32
lines changed

.travis.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,8 @@ jobs:
1010
- stage: check contract format
1111
script:
1212
- |
13-
contractErrors=$(node checkContract.js);
14-
if [[ $contractErrors != 0 ]]; then
15-
echo "Formatting errors! Please check your object keys spellings, commas and or other things that might invalidate your JSON and try again";
16-
exit 1;
17-
else
18-
echo "No errors";
19-
exit 0;
20-
fi
13+
node checkContract.js;
2114
- stage: check token format
2215
script:
2316
- |
24-
tokenErrors=$(node checkToken.js);
25-
if [[ $tokenErrors != 0 ]]; then
26-
echo "Formatting errors! Please check your object keys spellings, commas and or other things that might invalidate your JSON and try again";
27-
exit 1;
28-
else
29-
echo "No errors";
30-
exit 0;
31-
fi
17+
node checkToken.js;

checkContract.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const fs = require("fs");
2-
const contractsDirectory = "./src/contracts/";
3-
const Schema = require("validate");
1+
const fs = require('fs');
2+
const contractsDirectory = './src/contracts/';
3+
const Schema = require('validate');
44
const contract = new Schema({
55
name: {
66
type: String,
@@ -20,20 +20,19 @@ const contract = new Schema({
2020
}
2121
});
2222

23-
let errors = 0;
24-
2523
function run() {
24+
let errors = 0;
2625
fs.readdirSync(contractsDirectory).forEach(folder => {
2726
fs.readdirSync(`${contractsDirectory}/${folder}`).forEach(file => {
2827
const obj = JSON.parse(
29-
fs.readFileSync(`${contractsDirectory}/${folder}/${file}`, "utf8")
28+
fs.readFileSync(`${contractsDirectory}/${folder}/${file}`, 'utf8')
3029
);
3130
if (contract.validate(obj) === false) {
32-
errors++;
31+
process.exit(1);
3332
}
3433
});
3534
});
36-
return errors;
35+
process.exit(0);
3736
}
3837

3938
run();

checkToken.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const fs = require("fs");
2-
const tokensDirectory = "./src/tokens/";
3-
const Schema = require("validate");
1+
const fs = require('fs');
2+
const tokensDirectory = './src/tokens/';
3+
const Schema = require('validate');
44
const token = new Schema({
55
symbol: {
66
type: String,
@@ -93,20 +93,17 @@ const token = new Schema({
9393
}
9494
});
9595

96-
let errors = 0;
97-
9896
function run() {
9997
fs.readdirSync(tokensDirectory).forEach(folder => {
10098
fs.readdirSync(`${tokensDirectory}/${folder}`).forEach(file => {
10199
const obj = JSON.parse(
102-
fs.readFileSync(`${tokensDirectory}/${folder}/${file}`, "utf8")
100+
fs.readFileSync(`${tokensDirectory}/${folder}/${file}`, 'utf8')
103101
);
104102
if (token.validate(obj) === false) {
105-
errors++;
103+
process.exit(1);
106104
}
107105
});
108106
});
109-
return errors;
110107
}
111108

112109
run();

0 commit comments

Comments
 (0)