How to use the web-ext-native-msg.isDir function in web-ext-native-msg

To help you get started, we’ve selected a few web-ext-native-msg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asamuzaK / withExEditorHost / modules / setup.js View on Github external
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;
};
github asamuzaK / withExEditorHost / modules / setup.js View on Github external
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;
};
github asamuzaK / withExEditorHost / modules / main.js View on Github external
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);
  }
};
github asamuzaK / withExEditorHost / modules / setup.js View on Github external
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?`);
github asamuzaK / withExEditorHost / modules / setup.js View on Github external
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?`);