Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
chore: review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
giulianok committed Apr 16, 2024
1 parent 12e8ebd commit 08d7262
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('write-to-module-config', () => {

it('successfully writes to module config', () => {
writeToModuleConfig({ my: 'module-config' });
expect(fs.writeFileSync).toHaveBeenCalledWith('/mock-path/build/1.2.3/module-config.json', '{\n "my": "module-config"\n}');
expect(fs.writeFileSync).toHaveBeenCalledWith('/mock-path/build/1.2.3/module-config.json', '{"my":"module-config"}');
});
});

Expand All @@ -62,7 +62,7 @@ describe('write-to-module-config', () => {
writeToModuleConfig({ my: 'module-config' });
expect(fs.writeFileSync).toHaveBeenCalledWith(
'/mock-path/build/1.2.3/module-config.json',
'{\n "hello": "im here",\n "my": "module-config"\n}'
'{"hello":"im here","my":"module-config"}'
);
});
});
Expand Down
3 changes: 2 additions & 1 deletion packages/one-app-bundler/utils/writeToModuleConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ export function writeToModuleConfig(newData) {
const { packageJson } = readPackageUpSync();
const configPath = path.resolve(process.cwd(), 'build', packageJson.version, 'module-config.json');
const config = fs.existsSync(configPath) ? JSON.parse(fs.readFileSync(configPath, 'utf8')) : {};

fs.writeFileSync(configPath, JSON.stringify({
...config,
...newData,
}, null, 2));
}));
}

0 comments on commit 08d7262

Please sign in to comment.