@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
45 lines • 1.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const schema_1 = require("@sprucelabs/schema");
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
const spruce_templates_1 = require("@sprucelabs/spruce-templates");
class EsLint9Migrator {
static disk = spruce_skill_utils_1.diskUtil;
static Class;
cwd;
constructor(options) {
const { cwd } = options;
this.cwd = cwd;
}
static Migrator(options) {
(0, schema_1.assertOptions)(options, ['cwd']);
return new (this.Class ?? this)(options);
}
async migrate() {
const didDeleteFile = this.deleteFileIfExists('.eslintignore');
this.deleteFileIfExists('.eslintrc.js');
if (didDeleteFile) {
await this.updateVsCodeSettingsIfExists();
}
}
async updateVsCodeSettingsIfExists() {
const settings = await spruce_templates_1.templates.vsCodeSettings();
const destination = this.disk.resolvePath(this.cwd, '.vscode', 'settings.json');
if (this.disk.doesFileExist(destination)) {
this.disk.writeFile(destination, settings);
}
}
deleteFileIfExists(filename) {
const path = this.disk.resolvePath(this.cwd, filename);
if (this.disk.doesFileExist(path)) {
this.disk.deleteFile(path);
return true;
}
return false;
}
get disk() {
return EsLint9Migrator.disk;
}
}
exports.default = EsLint9Migrator;
//# sourceMappingURL=EsLint9Migrator.js.map