Skip to content

Commit dea8d33

Browse files
committed
fix: pnpm workspace includes placeholder replacements
1 parent 3c0badb commit dea8d33

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

packages/init/src/Init/FileHandlers/PNPMWorkspace.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import appRootPath from 'app-root-path';
99
import * as Placeholders from '../../Placeholders.js';
1010
import * as Plugin from '@qui-cli/plugin';
1111
import prettier from 'prettier';
12+
import { Log } from '@qui-cli/log';
1213

1314
export const handle: FileHandler['handle'] = async ({
1415
srcPath,
@@ -17,11 +18,11 @@ export const handle: FileHandler['handle'] = async ({
1718
}) => {
1819
destPath = path.join(appRootPath.toString(), path.basename(destPath));
1920
let changed = false;
21+
const proposal = yaml.parse(
22+
Placeholders.replaceAll(fs.readFileSync(srcPath, 'utf8'))
23+
);
2024
if (fs.existsSync(destPath)) {
21-
const workspace = yaml.parse(
22-
Placeholders.replaceAll(fs.readFileSync(destPath, 'utf8'))
23-
);
24-
const proposal = yaml.parse(fs.readFileSync(srcPath, 'utf8'));
25+
const workspace = yaml.parse(fs.readFileSync(destPath, 'utf8'));
2526
for (const key in proposal) {
2627
const update = merge(proposal[key], workspace[key]);
2728
await Confirm.withDiff({
@@ -43,9 +44,13 @@ export const handle: FileHandler['handle'] = async ({
4344
filepath: destPath
4445
})
4546
);
47+
Log.info(`${Colors.path(destPath, Colors.keyword)} updated`);
48+
} else {
49+
Log.info(`${Colors.path(destPath, Colors.keyword)} up-to-date`);
4650
}
4751
} else {
48-
fs.copyFileSync(srcPath, destPath);
52+
fs.writeFileSync(destPath, yaml.stringify(proposal));
53+
Log.info(`${Colors.path(destPath, Colors.keyword)} created`);
4954
return `Changes have been made to ${Colors.path(path.join(process.cwd(), 'pnpm-workspace.yaml'), Colors.keyword)}, please verify lockfile status`;
5055
}
5156
};

0 commit comments

Comments
 (0)