Skip to content

Commit

Permalink
Fixed file copy, added changesets
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugos68 committed Sep 22, 2023
1 parent fe650eb commit 7ce3d3d
Show file tree
Hide file tree
Showing 6 changed files with 10,725 additions and 8,098 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-poets-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'capkit': minor
---

Fixed files copy
21 changes: 15 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import { Command } from 'commander';
import { intro, text, multiselect, confirm, cancel, outro, spinner } from '@clack/prompts';
import { promises as fs, existsSync } from 'fs';
import { asyncExec, getConfigExtension, whichPMRuns } from './util.js';
import { asyncExec, getConfigExtension, getPM, isDirectory } from './util.js';
import path from 'path';
import { fileURLToPath } from 'url';

const program = new Command();

Expand Down Expand Up @@ -117,7 +119,7 @@ async function promptOptions() {
});
}

const pm = whichPMRuns().name;
const pm = getPM();

return {
name,
Expand Down Expand Up @@ -211,11 +213,18 @@ async function initializeProject({
start: 'Copying \x1b[1mhotreload scripts\x1b[0m',
stop: 'Successfully copied \x1b[1mhotreload scripts\x1b[0m',
task: async () => {
const root = process.cwd();
if (!existsSync(`${root}/scripts`)) await fs.mkdir(`${root}/scripts`);
const packageDir = path.dirname(fileURLToPath(import.meta.url));
const consumerDir = process.cwd();

if (!existsSync(`${consumerDir}/scripts`) || !isDirectory(`${consumerDir}/scripts`))
await fs.mkdir(`${consumerDir}\\scripts`);

return Promise.all([
fs.copyFile(`${root}/assets/hotreload.js`, `${root}/scripts/hotreload.js`),
fs.copyFile(`${root}/assets/hotreload-cleanup.js`, `${root}/scripts/hotreload-cleanup.js`)
fs.copyFile(`${packageDir}/assets/hotreload.js`, `${consumerDir}/scripts/hotreload.js`),
fs.copyFile(
`${packageDir}/assets/hotreload-cleanup.js`,
`${consumerDir}/scripts/hotreload-cleanup.js`
)
]);
}
});
Expand Down
Loading

0 comments on commit 7ce3d3d

Please sign in to comment.