-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d02ad18
commit 5be9670
Showing
8 changed files
with
132 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
# From https://github.com/facebook/react/blob/master/scripts/authors | ||
# Generate an AUTHORS file based on the output of git shortlog. It uses ABC | ||
# order, strips out leading spaces and numbers, then filters out specific | ||
# authors. | ||
|
||
git shortlog -sen \ | ||
| perl -spe 's/^\s+\d+\s+//' \ | ||
> misc/CONTRIBUTORS | ||
|
||
echo 'Updated contributors' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
#!/usr/bin/env bash | ||
#!/usr/bin/env node | ||
|
||
set -ex | ||
|
||
yarn build | ||
./scripts/contributors | ||
|
||
# Add dist files not generated before | ||
git ls-files 'dist/*.js*' | xargs git add | ||
git ls-files 'misc/*' | xargs git add | ||
(git commit -m "chore: add auto generated files" && git push && exit 1) || echo 'Files up to date' | ||
const gitAddCommitPush = require('../src/gitaddcommitpush'); | ||
gitAddCommitPush({ | ||
preCommand: ['yarn build', 'sh ./scripts/contributors'], | ||
files: ['dist/*.js*', 'misc/*'], | ||
commitMsg: 'chore: add auto generated files' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,37 @@ | ||
const spawn = require('child_process').spawn; | ||
const execa = require('child_process').exec; | ||
|
||
function exec(command, options = {}) { | ||
return new Promise((res, rej) => { | ||
execa(command, options, (err, stdout, stderr) => { | ||
if (stdout) process.stdout.write(`out: ${stdout}`); | ||
if (stderr) process.stderr.write(`err: ${stderr}`); | ||
if (err !== null) { | ||
process.stderr.write(`exec error: ${err}`); | ||
rej(err); | ||
} | ||
res({ stdout, stderr }); | ||
process.stdout.write(`Running command: ${command} \n`); | ||
if (command.indexOf('sh') === 0) { | ||
options.stdio = options.stdio || 'inherit'; | ||
return new Promise((res, rej) => { | ||
const [c, ...args] = command.split(' '); | ||
const runner = spawn(c, args, options); | ||
runner.on('close', (code) => { | ||
if (code !== 0) { | ||
process.stdout.write(`Command exited with code ${code}: ${command} \n`); | ||
rej(code); | ||
} else { | ||
process.stdout.write(`Finished command: ${command} \n`); | ||
res(); | ||
} | ||
}); | ||
}); | ||
}); | ||
} else { | ||
return new Promise((res, rej) => { | ||
execa(command, options, (err, stdout, stderr) => { | ||
if (stdout) process.stdout.write(`out: ${stdout} \n`); | ||
if (stderr) process.stderr.write(`err: ${stderr} \n`); | ||
if (err !== null) { | ||
process.stderr.write(`exec error: ${err}`); | ||
rej(err); | ||
} | ||
res({ stdout, stderr }); | ||
process.stdout.write(`Finished command: ${command} \n`); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = exec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const exec = require('./exec'); | ||
|
||
module.exports = async function({ | ||
preCommand = false, | ||
files = '*', | ||
commitMsg = 'chore: add new files', | ||
push = true | ||
} = {}) { | ||
if (preCommand) { | ||
if (Array.isArray(preCommand)) { | ||
for (let i = 0; i < preCommand.length; i++) { | ||
await exec(preCommand[i]); | ||
} | ||
} else { | ||
await exec(preCommand); | ||
} | ||
} | ||
if (Array.isArray(files)) { | ||
for (let i = 0; i < files.length; i++) { | ||
await exec(`git ls-files '${files[i]}' | xargs git add`); | ||
} | ||
} else { | ||
await exec(`git ls-files '${files}' | xargs git add`); | ||
} | ||
await exec(`git commit -m "${commitMsg}"`); | ||
if (push) await exec(`git push`).then(({ stdout }) => { | ||
console.log(stdout, stdout === 'Everything up-to-date'); | ||
}); | ||
}; |