Skip to content

Commit

Permalink
fix: 修复 windows 系统下无法正常初始化 git 仓库的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
codexu committed Nov 17, 2022
1 parent b2563d4 commit 06d742e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "x-build",
"version": "6.2.4",
"version": "6.2.5",
"description": "",
"main": "bin/x-build.js",
"bin": {
Expand All @@ -11,8 +11,7 @@
"test": "npm uninstall -g x-build && rimraf bin && rimraf test && tsc --build && npm link && x-build create test",
"test:add": "rimraf bin && rimraf test && tsc --build && sudo npm link && x add",
"dev": "ts-node-dev --respawn --transpile-only src/x-build.ts",
"build": "rimraf bin && tsc --build",
"push": "rimraf bin && tsc --build && nrm use npm && npm publish"
"build": "tsc --build"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default async function (name: string): Promise<void> {
// Git 初始化
await cmdIgnore('git', ['init'])
await cmdIgnore('git', ['add .'])
// await cmdIgnore('git', ['commit', ' -m', '"Initialize by X-BUILD"'])
await cmdIgnore('git', ['commit', '-m', '"Initialize by X-BUILD"'])

console.log(`> 成功初始化 Git 仓库`);

Expand Down
8 changes: 7 additions & 1 deletion src/utils/createSpawnCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ function createSpawnCmd(dest: string, stdio: StdioOptions = 'inherit') {
shell: true
});
return new Promise((resolve, reject) => {
ls.on('close', (code) => { code === 0 ? resolve(true) : reject(new Error()) });
ls.on('close', (code) => {
if (code === 0) {
resolve(true)
} else {
reject(new Error(`command error: ${cmd} ${args.join(' ')}`));
}
});
})
};
}
Expand Down

0 comments on commit 06d742e

Please sign in to comment.