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 createTmpFile = async (obj = {}) => {
const {data, value} = obj;
let filePath;
if (data) {
const {
dataId, dir, extType, host, incognito, mode, syncAuto, tabId,
windowId,
} = data;
if (dataId && dir && extType && host && tabId && windowId) {
const dirPath = await createDirectory(
path.join(TMPDIR_APP, dir, windowId, tabId, host), PERM_DIR,
);
const fileId = [windowId, tabId, host, dataId].join("_");
const fileName = dataId && encodeURIComponent(dataId);
filePath = dirPath && fileName && extType &&
await createFile(path.join(dirPath, fileName + extType), value,
{encoding: CHAR, flag: "w", mode: PERM_FILE});
filePath && dir && fileMap[dir] &&
fileMap[dir].set(fileId, {data, filePath});
if (!incognito && mode === MODE_EDIT && syncAuto) {
const opt = {
persistent: true,
recursive: false,
encoding: CHAR,
};
fileMap[FILE_WATCH].set(filePath, watch(filePath, opt, watchTmpFile));
} else {
fileMap[FILE_WATCH].has(filePath) && await unwatchFile(filePath);
}
}
}
return {