Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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: [
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;
}
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: [
}
// 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;
}
.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 {
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,