How to use the md5-file/promise function in md5-file

To help you get started, we’ve selected a few md5-file 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 ibi-group / datatools-ui / __tests__ / end-to-end.js View on Github external
const files = await fs.readdir(downloadsDir)
      let feedVersionDownloadFile = ''
      // assume that this file will be the only one matching the feed source ID
      for (const file of files) {
        if (file.indexOf(feedSourceId.replace(/:/g, '')) > -1) {
          feedVersionDownloadFile = file
          break
        }
      }
      if (!feedVersionDownloadFile) {
        throw new Error('Feed Version gtfs file not found in Downloads folder!')
      }

      // verify that file has same hash as gtfs file that was uploaded
      const filePath = path.join(downloadsDir, feedVersionDownloadFile)
      expect(await md5File(filePath)).toEqual(await md5File(gtfsUploadFile))

      // delete file
      await fs.remove(filePath)
    }, defaultTestTimeout)
github ashmind / SharpLab / source / WebApp / build.ts View on Github external
const html = task('html', async () => {
    const iconDataUrl = await getIconDataUrl();
    const templates = await getCombinedTemplates();
    const [jsHash, cssHash] = await parallel(
        md5File('wwwroot/app.min.js'),
        md5File('wwwroot/app.min.css')
    );
    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
    let html = (await jetpack.readAsync(paths.from.html))!;
    html = html
        .replace('{build:js}', 'app.min.js?' + jsHash)
        .replace('{build:css}', 'app.min.css?' + cssHash)
        .replace('{build:templates}', templates)
        .replace('{build:favicon-svg}', iconDataUrl);
    html = htmlMinifier.minify(html, { collapseWhitespace: true });
    await jetpack.writeAsync(paths.to.html, html);
}, {
    watch: [
github joelday / papyrus-lang / src / papyrus-lang-vscode / src / debugger / DebugSupportInstallService.ts View on Github external
return DebugSupportInstallState.installed;
        }

        // For clarity and consistency, the plugin is being renamed to end with Fallout4.dll
        // This handles the case where the old version is installed.
        const legacyInstalledPluginPath = await this.getPluginInstallPath(game, true);
        if (game === PapyrusGame.fallout4 && (await exists(legacyInstalledPluginPath))) {
            return DebugSupportInstallState.incorrectVersion;
        }

        const installedPluginPath = await this.getPluginInstallPath(game, false);
        if (!(await exists(installedPluginPath))) {
            return DebugSupportInstallState.notInstalled;
        }

        const installedHash = await md5File(installedPluginPath);
        const bundledHash = await md5File(this.getBundledPluginPath(game));

        if (installedHash !== bundledHash) {
            return DebugSupportInstallState.incorrectVersion;
        }

        return DebugSupportInstallState.installed;
    }
github ashmind / SharpLab / source / WebApp / build.ts View on Github external
const html = task('html', async () => {
    const iconDataUrl = await getIconDataUrl();
    const templates = await getCombinedTemplates();
    const [jsHash, cssHash] = await parallel(
        md5File('wwwroot/app.min.js'),
        md5File('wwwroot/app.min.css')
    );
    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
    let html = (await jetpack.readAsync(paths.from.html))!;
    html = html
        .replace('{build:js}', 'app.min.js?' + jsHash)
        .replace('{build:css}', 'app.min.css?' + cssHash)
        .replace('{build:templates}', templates)
        .replace('{build:favicon-svg}', iconDataUrl);
    html = htmlMinifier.minify(html, { collapseWhitespace: true });
    await jetpack.writeAsync(paths.to.html, html);
}, {
    watch: [
github joelday / papyrus-lang / src / papyrus-lang-vscode / src / debugger / DebugSupportInstallService.ts View on Github external
}

        // For clarity and consistency, the plugin is being renamed to end with Fallout4.dll
        // This handles the case where the old version is installed.
        const legacyInstalledPluginPath = await this.getPluginInstallPath(game, true);
        if (game === PapyrusGame.fallout4 && (await exists(legacyInstalledPluginPath))) {
            return DebugSupportInstallState.incorrectVersion;
        }

        const installedPluginPath = await this.getPluginInstallPath(game, false);
        if (!(await exists(installedPluginPath))) {
            return DebugSupportInstallState.notInstalled;
        }

        const installedHash = await md5File(installedPluginPath);
        const bundledHash = await md5File(this.getBundledPluginPath(game));

        if (installedHash !== bundledHash) {
            return DebugSupportInstallState.incorrectVersion;
        }

        return DebugSupportInstallState.installed;
    }
github anther / smashladder-desktop / app / actions / dolphinSettings.js View on Github external
.then(selectedPath => {
			if (!selectedPath) {
				throw new Error('No path was selected');
			}
			const theDirectory = path.dirname(selectedPath);

			console.log('selectedPath');
			dispatch({
				type: MELEE_ISO_VERIFY_BEGIN
			});
			md5File(selectedPath)
				.then((hash) => {
					console.log('the hash!', hash);
					const hashes = require('../constants/meleeHashes.json');
					const buildFound = hashes[hash];
					if (buildFound) {
						if (hash === '0e63d4223b01d9aba596259dc155a174') {
							dispatch({
								type: MELEE_ISO_VERIFY_SUCCESS
							});
						} else {
							dispatch({
								type: MELEE_ISO_VERIFY_FAIL,
								payload: `Found the wrong melee build, the selected ISO is ${buildFound}`
							});
						}
					} else {
github dreamnettech / dreamtime / src / workers / fs / worker.js View on Github external
async function getMetadata(filepath) {
  const exists = existsSync(filepath)

  const promises = [
    new Promise((resolve) => { resolve(mime.lookup(filepath)) }),
    new Promise((resolve) => { resolve(parse(filepath)) }),
  ]

  if (exists) {
    promises.push(
      stat(filepath),
      md5File(filepath),
      readFile(filepath, 'base64'),
    )
  } else {
    promises.push(
      Promise.resolve(),
      Promise.resolve(),
      Promise.resolve(),
    )
  }

  const [
    mimetype,
    { name, ext, dir },
    stats,
    md5,
    base64,

md5-file

Get the MD5-sum of a given file, with low memory usage, even on huge files.

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis