You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

27 lines
833 B

/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const fs = require('fs-extra');
const Base = require('../base');
const CONFIG_TPL_PATH = path.join(__dirname, './template/imove.config.js.tpl');
const OUTPUT_FILE_PATH = path.join(process.cwd(), 'imove.config.js');
class Init extends Base {
getProjectName() {
const pkgPath = path.join(this.projectPath, 'package.json');
const pkgJson = fs.readJSONSync(pkgPath);
return pkgJson.name;
}
getOutputContent() {
const tplContent = fs.readFileSync(CONFIG_TPL_PATH, 'utf-8');
return tplContent.replace('{projectName}', `'${this.getProjectName()}'`);
}
run() {
fs.outputFileSync(OUTPUT_FILE_PATH, this.getOutputContent());
console.log(`Create ${OUTPUT_FILE_PATH} at successfully!`);
}
}
module.exports = Init;