How to use the web-ext-native-msg.createFile 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 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 {