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)
import * as md5 from "md5-file";
import * as md5Promise from "md5-file/promise";
// $ExpectType void
md5("test.txt", (err, hash) => {
return;
});
// $ExpectType string
md5.sync("text.txt");
// $ExpectType Promise
md5Promise("test.txt");
// $ExpectType string
md5Promise.sync("text.txt");
const uploadDataPath = `${PATH_UPLOADDATA}/${dataUid}`;
const options = {
hostname,
port : port,
path : `${PATH_UPLOADDATA}/${dataUid}${creds}`,
method : 'POST',
protocol : 'https:',
rejectUnauthorized: false
};
console.log(`uploadData(${dataUid}) : ${options.hostname}:${options.port}${options.path}`);
const stats = fs.statSync(dataPath);
// console.log(stats);
const dataSize = stats['size'];
const dataMD5 = md5File.sync(dataPath);
// console.log('uploadData DATAUID ', dataUid);
// console.log('uploadData DATAMD5SUM ', dataMD5);
// console.log('uploadData DATASIZE ', dataSize);
// console.log('uploadData DATAFILE ', dataPath);
const dataForm = new FormData();
dataForm.append('DATAUID', dataUid);
dataForm.append('DATAMD5SUM', dataMD5);
dataForm.append('DATASIZE', dataSize);
dataForm.append('DATAFILE', fs.createReadStream(dataPath));
dataForm.submit(options, function(err, res) {
if (err) {
reject('uploadData error ' + err);
return;
}
reporter.linkWarning(href, file.path, 'Potentially broken image link detected.');
return href;
}
reporter.brokenLink(href, file.path);
throw new Error('Broken link detected. Stopping build.')
}
// If we're dealing with an asset, give it a name that won't collide, and copy
// it to a central directory.
// TODO(shyndman): This feels out of place here. These methods are about
// rewriting links, not copying assets.
if (patterns.newAssetPathPattern().test(srcLocalUrl.pathname)) {
const destLocalPath = path.join(
CONTENT_ASSETS_PATH,
md5File.sync(srcLocalUrl.pathname) +
path.extname(srcLocalUrl.pathname));
const destAssetHref = path.join(site.siteRoot || '/', destLocalPath);
fs.copySync(srcLocalUrl.pathname, path.join(BuildDir.STAGE, destLocalPath));
return destAssetHref;
}
const pathWithReadme = path.join(srcLocalUrl.pathname, 'README.md');
if (srcPathsToFiles.has(pathWithReadme)) {
srcLocalUrl.pathname = pathWithReadme;
}
// If the specified path has an associated markdown file in the site, rewrite
// the link to point to it, including the search and hash.
if (srcPathsToFiles.has(srcLocalUrl.pathname)) {
const destFile = srcPathsToFiles.get(srcLocalUrl.pathname);
const destLocalUrl = url.parse(
gulp.task('html', () => {
const roslynVersion = getRoslynVersion();
const faviconSvg = fs.readFileSync('favicon.svg', 'utf8');
// http://codepen.io/jakob-e/pen/doMoML
const faviconSvgUrlSafe = faviconSvg
.replace(/"/g, '\'')
.replace(/%/g, '%25')
.replace(/#/g, '%23')
.replace(/{/g, '%7B')
.replace(/}/g, '%7D')
.replace(//g, '%3E')
.replace(/\s+/g,' ');
const jsHash = md5File.sync('wwwroot/app.min.js');
const cssHash = md5File.sync('wwwroot/app.min.css');
return gulp
.src('./index.html')
.pipe(g.htmlReplace({ js: 'app.min.js?' + jsHash, css: 'app.min.css?' + cssHash })) // eslint-disable-line prefer-template
.pipe(g.replace('{build:favicon-svg}', faviconSvgUrlSafe))
.pipe(g.replace('{build:roslyn-version}', roslynVersion))
.pipe(gulp.dest('wwwroot'));
});
function encrypt(passwd) {
let cipher = crypto.createCipher(algor, passwd),
decryptedFileLocation = findFileLocation(DECRYPTED_FILENAME),
decryptedFileFullPath = decryptedFileLocation + DECRYPTED_FILENAME,
encryptedFileFullPath = decryptedFileLocation + ENCRYPTED_FILENAME, // we write encrypted file at same location as where we found decrypted file
encBuff;
if (!passwd) {
throw new Error('encryption requires a password');
}
encBuff = Buffer.concat([cipher.update(readFile(decryptedFileFullPath)), cipher.final()]);
writeFile(encryptedFileFullPath, encBuff);
return md5FileSync(encryptedFileFullPath);
}
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;
}