UNPKG

iwa-cli

Version:

An ImmutableWebApp CLI using oclif and cosmiconfig

36 lines (35 loc) 1.38 kB
"use strict"; const tslib_1 = require("tslib"); const fs_1 = (0, tslib_1.__importDefault)(require("fs")); const path_1 = (0, tslib_1.__importDefault)(require("path")); const command_1 = require("@oclif/command"); const chalk_1 = (0, tslib_1.__importDefault)(require("chalk")); const helpers_1 = require("../helpers"); class RemoveCommand extends command_1.Command { async run() { const { args } = this.parse(RemoveCommand); const { input } = args; const inputLocation = path_1.default.join(process.cwd(), input); const inputContent = fs_1.default.readFileSync(inputLocation, { encoding: 'utf-8', }); const outputContent = (0, helpers_1.removeIWA)(inputContent); if (outputContent === inputContent) { this.log(chalk_1.default.yellowBright `No IWA configuration to remove!`); } else { fs_1.default.writeFileSync(inputLocation, outputContent); this.log(chalk_1.default.yellowBright `IWA configuration removed from file!`); } } } RemoveCommand.aliases = ['rm']; RemoveCommand.description = 'Removes injected configuration from an HTML file'; RemoveCommand.flags = { version: command_1.flags.version({ char: 'v' }), help: command_1.flags.help({ char: 'h' }), }; RemoveCommand.args = [ { name: 'input' }, ]; module.exports = RemoveCommand;