forked from flaviait/ng2-jspm-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-styles.js
44 lines (37 loc) · 900 Bytes
/
lint-styles.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
"use strict";
const program = require("commander");
const utils = require("../dev/utils");
const lintStyles = require("../dev/styles").lint;
program
.usage('[options] <files-glob>')
.option("-w, --watch", "Watch the styles")
.parse(process.argv);
program.files = program.args[0];
const printError = e => {
if (e.code === "ELINT") {
console.error(`There are ${e.count} linting errors:`);
console.error(e.output);
} else {
console.error(e.stack);
}
};
utils.getFiles(program.files)
.then(lintStyles)
.then(
() => console.log("No style linting errors"),
e => {
printError(e);
if (!program.watch) {
process.exit(1);
}
}
);
if (program.watch) {
const watch = require("../dev/watch");
watch(program.files, files => {
lintStyles(files).then(
() => console.log("No style linting errors"),
printError
)
});
}