@@ -9,6 +9,7 @@ import appRootPath from 'app-root-path';
99import * as Placeholders from '../../Placeholders.js' ;
1010import * as Plugin from '@qui-cli/plugin' ;
1111import prettier from 'prettier' ;
12+ import { Log } from '@qui-cli/log' ;
1213
1314export 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