devflow-prompts 1.0.0 → 1.0.1
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/bin/cli.js +7 -3
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -26,13 +26,14 @@ if (!fs.existsSync(targetRoot)) {
|
|
|
26
26
|
fs.mkdirSync(targetRoot, { recursive: true });
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
async function copyFile(src, dest) {
|
|
29
|
+
async function copyFile(src, dest, mode) {
|
|
30
30
|
try {
|
|
31
31
|
const srcContent = fs.readFileSync(src);
|
|
32
32
|
|
|
33
33
|
if (fs.existsSync(dest)) {
|
|
34
34
|
if (force) {
|
|
35
35
|
fs.writeFileSync(dest, srcContent);
|
|
36
|
+
if (mode) fs.chmodSync(dest, mode);
|
|
36
37
|
console.log(` [OVERWRITE] ${path.relative(process.cwd(), dest)}`);
|
|
37
38
|
} else {
|
|
38
39
|
const destContent = fs.readFileSync(dest);
|
|
@@ -42,12 +43,14 @@ async function copyFile(src, dest) {
|
|
|
42
43
|
} else {
|
|
43
44
|
const newDest = dest + '.new';
|
|
44
45
|
fs.writeFileSync(newDest, srcContent);
|
|
46
|
+
if (mode) fs.chmodSync(newDest, mode);
|
|
45
47
|
console.log(` [CONFLICT] ${path.relative(process.cwd(), dest)} exists with different content.`);
|
|
46
48
|
console.log(` -> Created ${path.relative(process.cwd(), newDest)}`);
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
} else {
|
|
50
52
|
fs.writeFileSync(dest, srcContent);
|
|
53
|
+
if (mode) fs.chmodSync(dest, mode);
|
|
51
54
|
console.log(` [CREATE] ${path.relative(process.cwd(), dest)}`);
|
|
52
55
|
}
|
|
53
56
|
} catch (err) {
|
|
@@ -74,7 +77,8 @@ async function copyDir(src, dest) {
|
|
|
74
77
|
if (entry.isDirectory()) {
|
|
75
78
|
await copyDir(srcPath, destPath);
|
|
76
79
|
} else {
|
|
77
|
-
|
|
80
|
+
const stat = fs.statSync(srcPath);
|
|
81
|
+
await copyFile(srcPath, destPath, stat.mode);
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
84
|
}
|
|
@@ -93,7 +97,7 @@ async function copyDir(src, dest) {
|
|
|
93
97
|
if (stats.isDirectory()) {
|
|
94
98
|
await copyDir(srcPath, destPath);
|
|
95
99
|
} else {
|
|
96
|
-
await copyFile(srcPath, destPath);
|
|
100
|
+
await copyFile(srcPath, destPath, stats.mode);
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
console.log(`\n✅ Done! Run 'cd devflow-prompts' to check the files.`);
|