packdir-cli
Version:
Packdir CLI
36 lines • 1.14 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const child_process_1 = require("child_process");
const fs_1 = require("fs");
class Open extends core_1.Command {
/**
* Get the start command on different OS.
* @returns Start command
*/
getCommandLine() {
switch (process.platform) {
case 'darwin': return 'open';
case 'win32': return 'start';
default: return 'xdg-open';
}
}
async run() {
const { args, flags } = await this.parse(Open);
if (args.filename) {
if ((0, fs_1.existsSync)(args.filename)) {
(0, child_process_1.exec)(this.getCommandLine() + ' ' + args.filename);
}
else {
console.log(`File ${args.filename} does NOT exist!`);
}
}
}
}
exports.default = Open;
Open.description = 'Open a file with the default application.';
Open.examples = [
'<%= config.bin %> <%= command.id %>',
];
Open.args = [{ name: 'filename', required: true }];
//# sourceMappingURL=open.js.map
;