Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
}
mergeMap(() =>
writeFileObservable(
CONFIG_FILE_PATH,
JSON.stringify(state$.value.config.toJS())
).pipe(map(actions.doneSavingConfig))
)
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);
})
);
})
);
catchError(err => {
if (err.code === "ENOENT") {
return writeFileObservable(
nteractConfigFilename,
JSON.stringify({
theme: "light"
})
);
}
throw err;
})
)
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);
})
);
})
);
};