spec-first-claude 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/init.js +5 -9
- package/package.json +1 -1
package/lib/init.js
CHANGED
|
@@ -18,6 +18,9 @@ function copyDir(src, dest, replacements) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function copyFile(src, dest, replacements) {
|
|
21
|
+
// Skip if file already exists (preserve user's files)
|
|
22
|
+
if (fs.existsSync(dest)) return;
|
|
23
|
+
|
|
21
24
|
const textExtensions = ['.md', '.yaml', '.yml', '.json', '.js', '.ts', '.gitignore', '.gitkeep', ''];
|
|
22
25
|
const ext = path.extname(src).toLowerCase();
|
|
23
26
|
const basename = path.basename(src);
|
|
@@ -37,15 +40,8 @@ function copyFile(src, dest, replacements) {
|
|
|
37
40
|
function init({ name, templatesDir, targetDir }) {
|
|
38
41
|
const dest = targetDir || path.resolve(process.cwd(), name);
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (files.length > 0) {
|
|
43
|
-
console.error(`Error: directory "${dest}" already exists and is not empty.`);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
console.log(`\nCreating project "${name}" in ${dest}\n`);
|
|
43
|
+
const existed = fs.existsSync(dest);
|
|
44
|
+
console.log(`\n${existed ? 'Initializing' : 'Creating'} project "${name}" in ${dest}\n`);
|
|
49
45
|
|
|
50
46
|
const replacements = { [PLACEHOLDER]: name };
|
|
51
47
|
copyDir(templatesDir, dest, replacements);
|