Skip to content

Commit 5c3383f

Browse files
authored
fix: singlequote git commit issue on Windows (#223)
* fix windows singlequote -> doublequote * git commands soft error handling
1 parent 928296b commit 5c3383f

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/saofile.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from "path";
22
import validate from "validate-npm-package-name";
33
import { exec } from "child_process";
44
import { promisify } from "util";
5+
import chalk from "chalk";
56

67
import { GeneratorConfig, Action } from "../@types/sao";
78
import {
@@ -295,15 +296,21 @@ const saoConfig: GeneratorConfig = {
295296
* Create an initial commit
296297
*/
297298
if (!debug) {
298-
// add
299-
await promisify(exec)(
300-
`git --git-dir=${saoInstance.outDir}/.git/ --work-tree=${saoInstance.outDir}/ add -A`,
301-
);
302-
// commit
303-
await promisify(exec)(
304-
`git --git-dir=${saoInstance.outDir}/.git/ --work-tree=${saoInstance.outDir}/ commit -m 'initial commit with superplate'`,
305-
);
306-
saoInstance.logger.info("created an initial commit.");
299+
try {
300+
// add
301+
await promisify(exec)(
302+
`git --git-dir=${saoInstance.outDir}/.git/ --work-tree=${saoInstance.outDir}/ add -A`,
303+
);
304+
// commit
305+
await promisify(exec)(
306+
`git --git-dir=${saoInstance.outDir}/.git/ --work-tree=${saoInstance.outDir}/ commit -m "initial commit with superplate"`,
307+
);
308+
saoInstance.logger.info("created an initial commit.");
309+
} catch (_) {
310+
console.log(
311+
chalk.yellow`An error occured while creating git commit.`,
312+
);
313+
}
307314
}
308315

309316
/**

0 commit comments

Comments
 (0)