Skip to content

Commit

Permalink
fix(ci): fix the problem that git does not exist during dev and build
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jul 30, 2020
1 parent 8e8a00a commit ab3ef33
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
4 changes: 3 additions & 1 deletion build/npm-hook/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const { exec } = shelljs;
*/
function ignoreCaseGit() {
try {
exec('git config core.ignorecase false ');
if (shell.which('git')) {
exec('git config core.ignorecase false ');
}
} catch (error) {}
}
ignoreCaseGit();
Expand Down
16 changes: 9 additions & 7 deletions build/task/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

const runjs = require('runjs');
const { successTip, errorTip } = require('../utils');
const shell = require('shelljs');

const { run } = runjs;

const createChangeLog = async () => {
try {
await run(
`conventional-changelog -p custom-config -i CHANGELOG.md -s -r 0&& git add CHANGELOG.md`,
{
async: true,
stdio: 'inherit',
}
);
let cmd = `conventional-changelog -p custom-config -i CHANGELOG.md -s -r 0 `;
if (shell.which('git')) {
cmd += '&& git add CHANGELOG.md';
}
await run(cmd, {
async: true,
stdio: 'inherit',
});
await run('prettier --write **/CHANGELOG.md ', {
async: true,
stdio: 'inherit',
Expand Down
12 changes: 8 additions & 4 deletions build/task/update-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const runjs = require('runjs');
const fs = require('fs-extra');
const resolve = require('../getCwdPath');
const { inquirerPrompt, successTip, errorTip } = require('../utils');
const shell = require('shelljs');

const { run } = runjs;
const { writeFileSync } = fs;
Expand Down Expand Up @@ -62,10 +63,13 @@ const updateVersion = async (msg = 'Please select this update to submit changes'
});
}

await run(` git add ./package.json `, {
async: true,
stdio: 'inherit',
});
if (shell.which('git')) {
await run(` git add ./package.json `, {
async: true,
stdio: 'inherit',
});
}

successTip(
`The version number has been updated successfully! The current version is ${pkg.version}!`
);
Expand Down

0 comments on commit ab3ef33

Please sign in to comment.