@iservice-dev/is-wp-plugin-kit 1.6.1 → 1.6.2
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/commands/init.js +0 -1
- package/bin/is-wp-plugin-kit.js +1 -1
- package/bin/utils.js +13 -5
- package/package.json +1 -1
package/bin/commands/init.js
CHANGED
package/bin/is-wp-plugin-kit.js
CHANGED
package/bin/utils.js
CHANGED
|
@@ -7,20 +7,28 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
7
7
|
/**
|
|
8
8
|
* Safely copy a file from the files directory to the current working directory
|
|
9
9
|
* @param {string} file - The filename to copy
|
|
10
|
+
* @param {string} destPath - Optional: custom destination path relative to cwd
|
|
10
11
|
*/
|
|
11
|
-
export function copy(file) {
|
|
12
|
+
export function copy(file, destPath) {
|
|
12
13
|
try {
|
|
13
14
|
const src = path.resolve(__dirname, '../files', file);
|
|
14
|
-
const dest =
|
|
15
|
-
process.cwd(),
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const dest = destPath
|
|
16
|
+
? path.resolve(process.cwd(), destPath)
|
|
17
|
+
: path.resolve(
|
|
18
|
+
process.cwd(),
|
|
19
|
+
file.replace(/^gitignore$/, '.gitignore')
|
|
20
|
+
);
|
|
18
21
|
|
|
19
22
|
if (!fs.existsSync(src)) {
|
|
20
23
|
console.error(`Error: Source file ${file} not found.`);
|
|
21
24
|
process.exit(1);
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
const destDir = path.dirname(dest);
|
|
28
|
+
if (!fs.existsSync(destDir)) {
|
|
29
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
fs.copyFileSync(src, dest);
|
|
25
33
|
console.log(`✓ Copied ${file}`);
|
|
26
34
|
} catch (error) {
|
package/package.json
CHANGED