Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadNotebookFile(uri) {
// console.log('LOAD NOTEBOOK FILE');
this.file = new File(uri);
let parsedFile = this.parseNotebookFile(this.file);
if (parsedFile.cells) {
parsedFile.cells = parsedFile.cells.map(cell => {
cell.metadata.id = uuid.v4();
cell.metadata.focus = false;
return cell;
});
} else {
parsedFile.cells = [
{
cell_type: 'code',
execution_count: null,
metadata: {
collapsed: true
},
outputs: [],
_resetNylasEnv() {
NylasEnv.workspaceViewParentSelector = '#jasmine-content';
// Don't actually write to disk
spyOn(NylasEnv, 'saveSync');
// prevent specs from modifying N1's menus
spyOn(NylasEnv.menu, 'sendToBrowserProcess');
FocusedPerspectiveStore._current = MailboxPerspective.forNothing();
spyOn(pathwatcher.File.prototype, "detectResurrectionAfterDelay").andCallFake(function detectResurrection() {
return this.detectResurrection();
});
}
_resetNylasEnv() {
NylasEnv.testOrganizationUnit = null;
NylasEnv.workspaceViewParentSelector = '#jasmine-content';
// Don't actually write to disk
spyOn(NylasEnv, 'saveSync');
// prevent specs from modifying N1's menus
spyOn(NylasEnv.menu, 'sendToBrowserProcess');
FocusedPerspectiveStore._current = MailboxPerspective.forNothing();
spyOn(pathwatcher.File.prototype, "detectResurrectionAfterDelay").andCallFake(function detectResurrection() {
return this.detectResurrection();
});
}
loadUserStylesheet() {
this.unwatchUserStylesheet();
const userStylesheetPath = this.styleManager.getUserStyleSheetPath();
if (!fs.isFileSync(userStylesheetPath)) {
return;
}
try {
this.userStylesheetFile = new File(userStylesheetPath);
this.userStylesheetSubscriptions = new CompositeDisposable();
const reloadStylesheet = () => this.loadUserStylesheet();
this.userStylesheetSubscriptions.add(
this.userStylesheetFile.onDidChange(reloadStylesheet)
);
this.userStylesheetSubscriptions.add(
this.userStylesheetFile.onDidRename(reloadStylesheet)
);
this.userStylesheetSubscriptions.add(
this.userStylesheetFile.onDidDelete(reloadStylesheet)
);
} catch (error) {
const message = `\
Unable to watch path: \`${path.basename(userStylesheetPath)}\`. Make sure
you have permissions to \`${userStylesheetPath}\`.
spyOn(Config.prototype, 'getRawValues').andCallFake(() => {
return fakePersistedConfig;
}
);
spyOn(Config.prototype, 'setRawValue').andCallFake(function(keyPath, value) {
if (keyPath) {
_.setValueForKeyPath(fakePersistedConfig, keyPath, value);
} else {
fakePersistedConfig = value;
}
return this.load();
});
NylasEnv.config = new Config();
NylasEnv.loadConfig();
spyOn(pathwatcher.File.prototype, "detectResurrectionAfterDelay").andCallFake(function() {
return this.detectResurrection();
});
let clipboardContent = 'initial clipboard content';
spyOn(clipboard, 'writeText').andCallFake(text => clipboardContent = text);
spyOn(clipboard, 'readText').andCallFake(() => clipboardContent);
advanceClock(1000);
addCustomMatchers(this);
return TimeOverride.resetSpyData();
});
saveAs (filePath) {
if (!filePath) throw new Error("Can't save buffer with no file path")
return this.saveTo(new File(filePath))
}
setPath (filePath) {
if (filePath === this.getPath()) return
return this.setFile(filePath && new File(filePath))
}