@naturalcycles/dev-lib 14.1.2 → 14.1.3

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.
@@ -25,12 +25,10 @@ async function lintAllCommand() {
25
25
  default: false,
26
26
  },
27
27
  }).argv;
28
- // todo: produce a cleaner "list of changed files"
29
- let gitStatusAtStart;
30
- const hadChangesBefore = (0, nodejs_lib_1.gitHasUncommittedChanges)();
31
- if ((commitOnChanges || failOnChanges) && hadChangesBefore) {
28
+ const needToTrackChanges = commitOnChanges || failOnChanges;
29
+ const gitStatusAtStart = gitStatus();
30
+ if (needToTrackChanges && gitStatusAtStart) {
32
31
  console.log('lint-all: git shows changes before run:');
33
- gitStatusAtStart = gitStatus();
34
32
  console.log(gitStatusAtStart);
35
33
  }
36
34
  // We run eslint BEFORE Prettier, because eslint can delete e.g unused imports.
@@ -43,27 +41,21 @@ async function lintAllCommand() {
43
41
  runActionLint();
44
42
  await runKTLint();
45
43
  console.log(`${(0, nodejs_lib_1.boldGrey)('lint-all')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
46
- if (commitOnChanges || failOnChanges) {
47
- // detect changes
48
- const hasChanges = (0, nodejs_lib_1.gitHasUncommittedChanges)();
49
- if (hasChanges) {
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`);
53
- }
54
- else {
55
- const msg = 'style(ci): ' + (0, js_lib_1._truncate)((0, nodejs_lib_1.commitMessageToTitleMessage)((0, nodejs_lib_1.getLastGitCommitMsg)()), 60);
56
- // pull, commit, push changes
57
- (0, nodejs_lib_1.gitPull)();
58
- (0, nodejs_lib_1.gitCommitAll)(msg);
59
- (0, nodejs_lib_1.gitPush)();
60
- }
61
- // fail on changes
62
- if (failOnChanges) {
63
- console.log(gitStatusAfter);
64
- console.log('lint-all failOnChanges: exiting with status 1');
65
- process.exitCode = 1;
66
- }
44
+ if (needToTrackChanges) {
45
+ const gitStatusAfter = gitStatus();
46
+ const hasChanges = gitStatusAfter !== gitStatusAtStart;
47
+ if (!hasChanges)
48
+ return;
49
+ const msg = 'style(ci): ' + (0, js_lib_1._truncate)((0, nodejs_lib_1.commitMessageToTitleMessage)((0, nodejs_lib_1.getLastGitCommitMsg)()), 60);
50
+ // pull, commit, push changes
51
+ (0, nodejs_lib_1.gitPull)();
52
+ (0, nodejs_lib_1.gitCommitAll)(msg);
53
+ (0, nodejs_lib_1.gitPush)();
54
+ // fail on changes
55
+ if (failOnChanges) {
56
+ console.log(gitStatusAfter);
57
+ console.log('lint-all failOnChanges: exiting with status 1');
58
+ process.exitCode = 1;
67
59
  }
68
60
  }
69
61
  }
@@ -97,7 +89,7 @@ function canRunBinary(name) {
97
89
  }
98
90
  function gitStatus() {
99
91
  try {
100
- return (0, node_child_process_1.execSync)('git status', {
92
+ return (0, node_child_process_1.execSync)('git status -s', {
101
93
  encoding: 'utf8',
102
94
  });
103
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "14.1.2",
3
+ "version": "14.1.3",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "tsn-debug": "tsn testScript.ts",