Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const createEditorConfig = async () => {
const configPath = setupOpts.get("configPath");
if (!isDir(configPath)) {
throw new Error(`No such directory: ${configPath}`);
}
const filePath = path.join(configPath, EDITOR_CONFIG_FILE);
const editorPath =
await handleEditorPathInput(setupOpts.get("editorFilePath"));
const cmdArgs = await handleCmdArgsInput(setupOpts.get("editorCmdArgs"));
const content = `${JSON.stringify({editorPath, cmdArgs}, null, INDENT)}\n`;
await createFile(filePath, content, {
encoding: CHAR,
flag: "w",
mode: PERM_FILE,
});
console.info(`Created: ${filePath}`);
return filePath;
};
const createEditorConfig = async () => {
const configPath = setupOpts.get("configPath");
if (!isDir(configPath)) {
throw new Error(`No such directory: ${configPath}`);
}
const filePath = path.join(configPath, EDITOR_CONFIG_FILE);
const editorPath =
await handleEditorPathInput(setupOpts.get("editorFilePath"));
const cmdArgs = await handleCmdArgsInput(setupOpts.get("editorCmdArgs"));
const content = `${JSON.stringify({editorPath, cmdArgs}, null, INDENT)}\n`;
await createFile(filePath, content, {
encoding: CHAR,
flag: "w",
mode: PERM_FILE,
});
console.info(`Created: ${filePath}`);
return filePath;
};
const handleExit = code => {
if (isDir(TMPDIR_APP)) {
removeDir(TMPDIR_APP, TMPDIR);
}
if (code) {
const msg = new Output().encode(hostMsg(`exit ${code}`, "exit"));
msg && process.stdout.write(msg);
}
};
const handleSetupCallback = (info = {}) => {
const {configDirPath: configPath} = info;
if (!isDir(configPath)) {
throw new Error(`No such directory: ${configPath}.`);
}
const editorArgs = setupOpts.get("editorArgs");
const editorPath = setupOpts.get("editorPath");
const overwriteEditorConfig = setupOpts.get("overwriteEditorConfig");
const file = path.join(configPath, EDITOR_CONFIG_FILE);
let func;
setupOpts.set("configPath", configPath);
if (isString(editorPath)) {
setupOpts.set("editorFilePath", editorPath.trim());
}
if (isString(editorArgs)) {
setupOpts.set("editorCmdArgs", new CmdArgs(editorArgs.trim()).toArray());
}
if (isFile(file) && !overwriteEditorConfig) {
const ans = readline.keyInYNStrict(`${file} already exists.\nOverwrite?`);
const handleSetupCallback = (info = {}) => {
const {configDirPath: configPath} = info;
if (!isDir(configPath)) {
throw new Error(`No such directory: ${configPath}.`);
}
const editorArgs = setupOpts.get("editorArgs");
const editorPath = setupOpts.get("editorPath");
const overwriteEditorConfig = setupOpts.get("overwriteEditorConfig");
const file = path.join(configPath, EDITOR_CONFIG_FILE);
let func;
setupOpts.set("configPath", configPath);
if (isString(editorPath)) {
setupOpts.set("editorFilePath", editorPath.trim());
}
if (isString(editorArgs)) {
setupOpts.set("editorCmdArgs", (new CmdArgs(editorArgs.trim())).toArray());
}
if (isFile(file) && !overwriteEditorConfig) {
const ans = readline.keyInYNStrict(`${file} already exists.\nOverwrite?`);