@lark-apaas/fullstack-cli 1.1.68-alpha.20260920210907 → 1.1.68-alpha.20260920222123
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/package.json
CHANGED
|
@@ -17,9 +17,35 @@ function failAndExit(step, body) {
|
|
|
17
17
|
process.exit(1);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
function getStagedFiles() {
|
|
21
|
+
const res = spawnSync(
|
|
22
|
+
'git',
|
|
23
|
+
['diff', '--cached', '--name-only', '--diff-filter=ACMR', '-z'],
|
|
24
|
+
{
|
|
25
|
+
cwd: process.cwd(),
|
|
26
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
27
|
+
encoding: 'utf8',
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
if (res.error) {
|
|
31
|
+
failAndExit('staged files', String(res.error.message || res.error));
|
|
32
|
+
}
|
|
33
|
+
if (res.status !== 0) {
|
|
34
|
+
failAndExit('staged files', `${res.stdout || ''}\n${res.stderr || ''}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (res.stdout || '').split('\0').filter(Boolean);
|
|
38
|
+
}
|
|
39
|
+
|
|
20
40
|
function runLint() {
|
|
21
41
|
const cwd = process.cwd();
|
|
22
|
-
const
|
|
42
|
+
const stagedFiles = getStagedFiles();
|
|
43
|
+
if (stagedFiles.length === 0) {
|
|
44
|
+
process.stdout.write('[pre-commit] No staged files to lint\n');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const res = spawnSync('npm', ['run', 'lint', '--', '--files', ...stagedFiles], {
|
|
23
49
|
cwd,
|
|
24
50
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
25
51
|
env: process.env,
|