Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getInfo(filePath, callback) {
// parameter validation
if (!filePath || typeof filePath !== 'string') {
return;
}
// create a key from path
const key = genrateKey(filePath);
// file load on file protocol
const uri = fileUrl(filePath);
const book = new Book(uri);
book.ready
.then(() => {
return book.locations.generate();
})
.then(locations => {
const meta = book.package.metadata;
const info = {
id: key,
title: meta.title,
author: meta.creator,
publisher: meta.publisher,
path: uri,
bookmarks: [],
export async function gitRepo(withRemote, branch = 'master') {
let cwd = tempy.directory();
await execa('git', ['init', ...(withRemote ? ['--bare'] : [])], {cwd});
const repositoryUrl = fileUrl(cwd);
if (withRemote) {
await initBareRepo(repositoryUrl, branch);
cwd = await gitShallowClone(repositoryUrl, branch);
} else {
await gitCheckout(branch, true, {cwd});
}
await execa('git', ['config', 'commit.gpgsign', false], {cwd});
return {cwd, repositoryUrl};
}
export async function gitRepo(withRemote, branch = 'master') {
let cwd = tempy.directory();
await execa('git', ['init'].concat(withRemote ? ['--bare'] : []), {cwd});
const repositoryUrl = fileUrl(cwd);
if (withRemote) {
await initBareRepo(repositoryUrl, branch);
cwd = await gitShallowClone(repositoryUrl);
} else {
await gitCheckout(branch, true, {cwd});
}
return {cwd, repositoryUrl};
}
function pathToFileURL (path) {
return fileUrl(path)
}
fullTokenRules['image'] = (token, context) => {
let url = attr(token, 'src');
if (!url.match(/(file|https?):/)) {
url = fileUrl(url);
}
const image = {
url: url,
width: undefined,
height: undefined,
padding: 0,
offsetX: 0,
offsetY: 0,
};
const padding = attr(token, 'pad');
if (padding) {
image.padding = parseInt(padding);
}
const offsetX = attr(token, 'offset-x');
let path = filterPathsToJustPlayable(filter, [url], true).map((p) => p.startsWith("http") ? p : fileURL(p));
if (path.length > 0) {
private onUserdirOpen() {
this.openAny(fileUrl(this.status.userDir));
}
_.forEach(messagesByFile, (messages, file) => publishDiagnostics(messages, fileUrl(file)));
});
openLastFile: boolean;
httpNodeAuth: {user: string, pass: string};
listenPort: string;
debugOut: boolean;
}
class BaseApplication {
private mainWindow: CustomBrowserWindow | null = null;
private customAutoUpdater: CustomAutoUpdater | null = null;
private appMenu: AppMenu | null = null;
private tray: CustomTray | null = null;
private app: App;
private loadingURL: string = fileUrl(
path.join(__dirname, "..", "loading.html")
);
private settingsURL: string = fileUrl(
path.join(__dirname, "..", "settings.html")
);
private config: ConfigManager;
private fileManager: FileManager;
private fileHistory: FileHistory;
private status: AppStatus;
private red: NodeREDApp;
constructor(app: App) {
this.app = app;
this.app.on("ready", this.onReady.bind(this));
this.app.on("activate", this.onActivated.bind(this));
this.app.on("window-all-closed", this.onWindowAllClosed.bind(this));
this.config = new ConfigManager(app.name);
this.fileManager = new FileManager(this.config);
this.fileHistory = new FileHistory(FILE_HISTORY_SIZE, ipcMain);