File | Lines added | Lines deleted |
---|---|---|
base.js | 1 | 1 |
lint.js | 8 | 2 |
pre-commit.js | 2 | 2 |
File base.js changed (mode: 100644) (index 58d4024..ed258b3) | |||
... | ... | module.exports = { | |
18 | 18 | }, | }, |
19 | 19 | print: function (message) { | print: function (message) { |
20 | 20 | cursor.green().write(message).reset().write("\n"); | cursor.green().write(message).reset().write("\n"); |
21 | }, | ||
21 | } | ||
22 | 22 | }; | }; |
File lint.js changed (mode: 100755) (index eb3d00a..0a010ee) | |||
1 | 1 | #!/usr/bin/env node | #!/usr/bin/env node |
2 | 2 | const { exec } = require("shelljs"), | const { exec } = require("shelljs"), |
3 | { print } = require("./base"), | ||
3 | 4 | files = exec(`git diff --staged --name-only | grep \.js$`).stdout.split("\n"); | files = exec(`git diff --staged --name-only | grep \.js$`).stdout.split("\n"); |
5 | |||
6 | print(__filename); | ||
7 | |||
4 | 8 | if (files.length > 1) { | if (files.length > 1) { |
5 | const params = files.join(" "); | ||
6 | exec(`npx prettier --write ${params}`); | ||
9 | const params = files.join(" "), | ||
10 | command = `npx prettier --write ${params}`; | ||
11 | print(command); | ||
12 | exec(command); | ||
7 | 13 | } | } |
File pre-commit.js changed (mode: 100755) (index 2ebea47..821ef42) | |||
... | ... | const shellExec = require("shelljs").exec, | |
8 | 8 | return shellExec(cmd); | return shellExec(cmd); |
9 | 9 | }; | }; |
10 | 10 | ||
11 | print("pre-commit"); | ||
12 | const stagedFiles = exec(`git diff --staged --name-only`,{silent:true}).stdout.split("\n"), | ||
11 | print(__filename); | ||
12 | const stagedFiles = shellExec(`git diff --staged --name-only`,{silent:true}).stdout.split("\n"), | ||
13 | 13 | hasChanges = stagedFiles.length > 1; | hasChanges = stagedFiles.length > 1; |
14 | 14 | if (hasChanges) { | if (hasChanges) { |
15 | 15 | exec("git stash --keep-index -q"); | exec("git stash --keep-index -q"); |