@naturalcycles/dev-lib 14.1.1 → 14.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cmd/lint-all.command.js +19 -2
- package/package.json +1 -1
|
@@ -25,7 +25,14 @@ async function lintAllCommand() {
|
|
|
25
25
|
default: false,
|
|
26
26
|
},
|
|
27
27
|
}).argv;
|
|
28
|
+
// todo: produce a cleaner "list of changed files"
|
|
29
|
+
let gitStatusAtStart;
|
|
28
30
|
const hadChangesBefore = (0, nodejs_lib_1.gitHasUncommittedChanges)();
|
|
31
|
+
if ((commitOnChanges || failOnChanges) && hadChangesBefore) {
|
|
32
|
+
console.log('lint-all: git shows changes before run:');
|
|
33
|
+
gitStatusAtStart = gitStatus();
|
|
34
|
+
console.log(gitStatusAtStart);
|
|
35
|
+
}
|
|
29
36
|
// We run eslint BEFORE Prettier, because eslint can delete e.g unused imports.
|
|
30
37
|
await (0, eslint_all_command_1.eslintAllCommand)();
|
|
31
38
|
if (node_fs_1.default.existsSync(`node_modules/stylelint`) &&
|
|
@@ -40,8 +47,9 @@ async function lintAllCommand() {
|
|
|
40
47
|
// detect changes
|
|
41
48
|
const hasChanges = (0, nodejs_lib_1.gitHasUncommittedChanges)();
|
|
42
49
|
if (hasChanges) {
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
const gitStatusAfter = gitStatus();
|
|
51
|
+
if (gitStatusAfter === gitStatusAtStart) {
|
|
52
|
+
console.log(`lint-all: git status is the same as before the run, will not commit`);
|
|
45
53
|
}
|
|
46
54
|
else {
|
|
47
55
|
const msg = 'style(ci): ' + (0, js_lib_1._truncate)((0, nodejs_lib_1.commitMessageToTitleMessage)((0, nodejs_lib_1.getLastGitCommitMsg)()), 60);
|
|
@@ -52,6 +60,7 @@ async function lintAllCommand() {
|
|
|
52
60
|
}
|
|
53
61
|
// fail on changes
|
|
54
62
|
if (failOnChanges) {
|
|
63
|
+
console.log(gitStatusAfter);
|
|
55
64
|
console.log('lint-all failOnChanges: exiting with status 1');
|
|
56
65
|
process.exitCode = 1;
|
|
57
66
|
}
|
|
@@ -86,3 +95,11 @@ function canRunBinary(name) {
|
|
|
86
95
|
return false;
|
|
87
96
|
}
|
|
88
97
|
}
|
|
98
|
+
function gitStatus() {
|
|
99
|
+
try {
|
|
100
|
+
return (0, node_child_process_1.execSync)('git status', {
|
|
101
|
+
encoding: 'utf8',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch { }
|
|
105
|
+
}
|