How to use file-url - 9 common examples

To help you get started, we’ve selected a few file-url 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 Janglee123 / eplee / src / shared / dbUtilis.js View on Github external
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: [],
github semantic-release / semantic-release / test / helpers / git-utils.js View on Github external
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};
}
github pvdlg / env-ci / test / helpers / git-utils.js View on Github external
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};
}
github gsuitedevs / md2googleslides / src / parser / extract_slides.ts View on Github external
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');
github ififfy / flipflip / src / renderer / components / player / SourceScraper.tsx View on Github external
    let path = filterPathsToJustPlayable(filter, [url], true).map((p) => p.startsWith("http") ? p : fileURL(p));
    if (path.length > 0) {
github sakazuki / node-red-desktop / src / main / main.ts View on Github external
private onUserdirOpen() {
    this.openAny(fileUrl(this.status.userDir));
  }
github antew / elm-lsp / lib / language-server.ts View on Github external
      _.forEach(messagesByFile, (messages, file) => publishDiagnostics(messages, fileUrl(file)));
    });
github sakazuki / node-red-desktop / src / main / main.ts View on Github external
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);

file-url

Convert a file path to a file url: `unicorn.jpg` → `file:///Users/sindresorhus/unicorn.jpg`

MIT
Latest version published 4 years ago

Package Health Score

56 / 100
Full package analysis

Popular file-url functions