How to use the fs-observable.writeFileObservable function in fs-observable

To help you get started, we’ve selected a few fs-observable 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 nteract / nteract / applications / desktop / src / notebook / epics / saving.ts View on Github external
return of(
          actions.saveFailed({
            contentRef: action.payload.contentRef,
            error: new Error("no notebook loaded to save")
          })
        );
      }

      const filepath = content.filepath;
      const appVersion = selectors.appVersion(state);
      const notebook = stringifyNotebook(
        toJS(
          model.notebook.setIn(["metadata", "nteract", "version"], appVersion)
        )
      );
      return writeFileObservable(filepath, notebook).pipe(
        map(() => {
          if (process.platform !== "darwin") {
            const notificationSystem = selectors.notificationSystem(
              state$.value
            );
            notificationSystem.addNotification({
              autoDismiss: 2,
              level: "success",
              title: "Save successful!"
            });
          }
          return actions.saveFulfilled({
            contentRef: action.payload.contentRef,
            model: {
              last_modified: new Date()
            }
github nteract / nteract / applications / desktop / src / notebook / epics / config.ts View on Github external
mergeMap(() =>
      writeFileObservable(
        CONFIG_FILE_PATH,
        JSON.stringify(state$.value.config.toJS())
      ).pipe(map(actions.doneSavingConfig))
    )
github nteract / nteract / applications / desktop / src / main / cli.ts View on Github external
const installShellCommandsObservable = (
  exe: string,
  rootDir: string,
  binDir: string
): Observable => {
  if (process.platform === "win32") {
    return setWinPathObservable(exe, rootDir, binDir);
  }
  const envFile = join(binDir, "nteract-env");
  return writeFileObservable(
    envFile,
    `NTERACT_EXE="${exe}"\nNTERACT_DIR="${rootDir}"`
  ).pipe(
    mergeMap(() => {
      const target = join(binDir, "nteract.sh");
      return createSymlinkObservable(target, "/usr/local/bin/nteract").pipe(
        catchError(() => {
          if (!process.env.HOME) {
            throw new Error("HOME not defined");
          }
          const dest = join(process.env.HOME, ".local/bin/nteract");
          return createSymlinkObservable(target, dest);
        })
      );
    })
  );
github nteract / nteract / applications / desktop / src / main / index.ts View on Github external
catchError(err => {
        if (err.code === "ENOENT") {
          return writeFileObservable(
            nteractConfigFilename,
            JSON.stringify({
              theme: "light"
            })
          );
        }
        throw err;
      })
    )
github nteract / nteract / applications / desktop / src / main / cli.js View on Github external
const installShellCommandsObservable = (
  exe: string,
  rootDir: string,
  binDir: string
) => {
  if (process.platform === "win32") {
    return setWinPathObservable(exe, rootDir, binDir);
  }
  const envFile = join(binDir, "nteract-env");
  return writeFileObservable(
    envFile,
    `NTERACT_EXE="${exe}"\nNTERACT_DIR="${rootDir}"`
  ).pipe(
    mergeMap(() => {
      const target = join(binDir, "nteract.sh");
      return createSymlinkObservable(target, "/usr/local/bin/nteract").pipe(
        catchError(() => {
          const dest = join(process.env.HOME, ".local/bin/nteract");
          return createSymlinkObservable(target, dest);
        })
      );
    })
  );
};

fs-observable

Observables for node fs

BSD-3-Clause
Latest version published 4 years ago

Package Health Score

68 / 100
Full package analysis