Skip to content

Commit

Permalink
Fix legacy config conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Cohee1207 committed Oct 11, 2024
1 parent 9dcf3c2 commit fa84b3e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions post-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ function convertConfig() {

try {
console.log(color.blue('Converting config.conf to config.yaml. Your old config.conf will be renamed to config.conf.bak'));
fs.renameSync('./config.conf', './config.conf.cjs'); // Force loading as CommonJS
const require = createRequire(import.meta.url);
const config = require(path.join(process.cwd(), './config.conf'));
fs.copyFileSync('./config.conf', './config.conf.bak');
fs.rmSync('./config.conf');
const config = require(path.join(process.cwd(), './config.conf.cjs'));
fs.copyFileSync('./config.conf.cjs', './config.conf.bak');
fs.rmSync('./config.conf.cjs');
fs.writeFileSync('./config.yaml', yaml.stringify(config));
console.log(color.green('Conversion successful. Please check your config.yaml and fix it if necessary.'));
} catch (error) {
console.error(color.red('FATAL: Config conversion failed. Please check your config.conf file and try again.'));
console.error(color.red('FATAL: Config conversion failed. Please check your config.conf file and try again.'), error);
return;
}
}
Expand Down

0 comments on commit fa84b3e

Please sign in to comment.