qforce
Version:
Commands to help with salesforce development.
46 lines (45 loc) • 2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("@oclif/command");
const cli_ux_1 = require("cli-ux");
const utility_1 = require("../../helper/utility");
const execa = require('execa');
const fs = require('fs');
class DevCode extends command_1.Command {
async run() {
cli_ux_1.default.action.start('Starting to code');
const { args, flags } = this.parse(DevCode);
let settings;
if (fs.existsSync(utility_1.getAbsolutePath('.qforce/settings.json'))) {
settings = JSON.parse(fs.readFileSync(utility_1.getAbsolutePath('.qforce/settings.json')));
}
const featureBranch = args.featureBranch;
const developBranch = args.developBranch || settings.developBranch;
execa('git', ['checkout', featureBranch]).catch((error) => this.log(error)).then((result) => {
return execa('git', ['merge-base', featureBranch, developBranch]);
}).catch((error) => this.log(error)).then((result) => {
return execa('git', ['diff', '--name-only', result.stdout, featureBranch]);
}).then((result) => {
for (let file of result.stdout.split('\n')) {
if (file.endsWith('-meta.xml'))
continue;
else
execa.sync('code', [file]);
}
cli_ux_1.default.action.stop();
}).catch((error) => {
cli_ux_1.default.action.stop(error);
});
}
}
exports.default = DevCode;
DevCode.description = 'Open all files committed in a branch in VS Code';
DevCode.aliases = ['code', 'dev:code'];
DevCode.flags = {
help: command_1.flags.help({ char: 'h' }),
// flag with a value (-n, --name=VALUE)
name: command_1.flags.string({ char: 'n', description: 'name to print' }),
// flag with no value (-f, --force)
force: command_1.flags.boolean({ char: 'f' }),
};
DevCode.args = [{ name: 'featureBranch' }, { name: 'developBranch' }];