Comparing version 1.0.5 to 1.0.6
@@ -32,3 +32,3 @@ #!/usr/bin/env node | ||
projectName = ymlConfig.project | ||
newWorkspace(projectName); | ||
newWorkspace(projectName, args['--force']); | ||
} else { | ||
@@ -39,8 +39,3 @@ throw 'project属性不能为空'; | ||
if (err?.code === 'EEXIST') { | ||
if (args['--force']) { | ||
newWorkspace(projectName); | ||
console.log('已覆盖'); | ||
} else { | ||
console.error(`${projectName}已存在,请在yml配置中设置一个不重复的project属性,或者使用-F覆盖`); | ||
} | ||
console.error(`${projectName}已存在,请在yml配置中设置一个不重复的project属性,或者使用-F覆盖`); | ||
} else if (err?.code === 'ENOENT') { | ||
@@ -53,3 +48,3 @@ console.error(`没有找到配置文件: ${configFileName}`); | ||
function newWorkspace(projectName) { | ||
function newWorkspace(projectName, force) { | ||
// .my-ci文件夹不存在则先创建 | ||
@@ -69,5 +64,17 @@ try { | ||
const wsInfoPath = path.resolve(os.homedir(), dataDir, projectName); | ||
fs.openSync(wsInfoPath, 'wx'); // 如果文件已经存在,会抛出错误 | ||
try { | ||
fs.openSync(wsInfoPath, 'wx'); // 如果文件已经存在,会抛出错误 | ||
} catch (e) { | ||
if (err?.code === 'EEXIST') { | ||
if (force) { | ||
fs.unlinkSync(wsInfoPath); | ||
console.log('删除已有work信息'); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
fs.writeFileSync(wsInfoPath, `PATH=${projectRootPath}`); | ||
console.log('my-ci project created successfully.'); | ||
} |
{ | ||
"name": "my-ci", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6300
162