Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
result.on('data', function(data) { res += data; });
result.on('end', function() { resolve(res); });
}).on('error', function(err) {
console.error(err);
reject(err);
});
}))[0].sha;
// download latest file
yield fetch(targetName, gitCommit, true);
var fileHash = yield computeSHA1(targetName);
// now rewrite this file!
file.expectedSHA1 = fileHash;
file.latestCommit = gitCommit;
yield fs.writeFile(testFilesPath, JSON.stringify(testFiles, null, '\t'), 'utf8');
console.log('Updated', testFilesPath);
});
const oldExists = yield fs.exists(this.blackListPath);
if (oldExists) {
old = yield fs.readFile(this.blackListPath, 'utf8');
}
const testBlackList = options.modes.reduce((tbl, mode) => {
this.stats.modes[mode].failList.forEach((fail) => {
if (!tbl.hasOwnProperty(fail.title)) {
tbl[fail.title] = {};
}
tbl[fail.title][mode] = fail.raw;
});
return tbl;
}, {});
const contents = JSON.stringify(testBlackList, null, " ");
if (ScriptUtils.booleanOption(options['rewrite-blacklist'])) {
yield fs.writeFile(this.blackListPath, contents, 'utf8');
} else if (allModes && oldExists) {
blacklistChanged = (contents !== old);
}
}
// Write updated tests from failed ones
if (options['update-tests'] ||
ScriptUtils.booleanOption(options['update-unexpected'])) {
var updateFormat = (options['update-tests'] === 'raw') ?
'raw' : 'actualNormalized';
var parserTests = yield fs.readFile(this.testFilePath, 'utf8');
this.stats.modes.wt2html.failList.forEach(function(fail) {
if (options['update-tests'] || fail.unexpected) {
var exp = new RegExp("(" + /!!\s*test\s*/.source +
JSUtils.escapeRegExp(fail.title) + /(?:(?!!!\s*end)[\s\S])*/.source +
")(" + JSUtils.escapeRegExp(fail.expected) + ")", "m");
async _writeFiles(outputDir) {
const utilsText = await fs.readFile(path.resolve(__dirname, "output/utils.js"));
await fs.writeFile(this.utilPath, utilsText);
const { interfaces, dictionaries, enumerations } = this.ctx;
for (const obj of interfaces.values()) {
let source = obj.toString();
let implFile = path.relative(outputDir, path.resolve(obj.opts.implDir, obj.name + this.ctx.implSuffix));
implFile = implFile.replace(/\\/g, "/"); // fix windows file paths
if (implFile[0] !== ".") {
implFile = "./" + implFile;
}
let relativeUtils = path.relative(outputDir, this.utilPath).replace(/\\/g, "/");
if (relativeUtils[0] !== ".") {
relativeUtils = "./" + relativeUtils;
}
.then(buffer => fs.writeFile(relative(`${index}.png`), buffer))
.catch(e => console.error(`${test.file}\n\n${e.stack}\n\n\n`));
.then(function (buffer) {
fs.writeFile(png, buffer)
.then(function () {
imageDiff({
actualImage: png,
expectedImage: expected,
diffImage: diff
}, function (err, imagesAreSame) {
should(err).not.ok;
should.ok(imagesAreSame, msg);
done();
});
})
.catch(ecb);
})
.catch(ecb);
.then(() => fs.writeFile(outputFilePath, file.contents))
.then(() => outputFilePath);
(userOutputPath) => {
if (userOutputPath) {
fs.writeFile(userOutputPath, colorsFileContents);
}
}
);
if (relativeUtils[0] !== ".") {
relativeUtils = "./" + relativeUtils;
}
source = `
"use strict";
const conversions = require("webidl-conversions");
const utils = require("${relativeUtils}");
${source}
const Impl = require("${implFile}.js");
`;
source = this._prettify(source);
await fs.writeFile(path.join(outputDir, obj.name + ".js"), source);
}
for (const obj of dictionaries.values()) {
let source = obj.toString();
let relativeUtils = path.relative(outputDir, this.utilPath).replace(/\\/g, "/");
if (relativeUtils[0] !== ".") {
relativeUtils = "./" + relativeUtils;
}
source = `
"use strict";
const conversions = require("webidl-conversions");
const utils = require("${relativeUtils}");
${source}
scrubWikitext: argv.scrubWikitext,
});
} else {
str = html;
}
} else {
str = out.wt;
}
var stdout = process.stdout;
stdout.write(str);
if (stdout.isTTY) {
stdout.write('\n');
}
if (argv.record) {
var nockCalls = nock.recorder.play();
yield fs.writeFile(
nocksFile,
"var nock = require('nock');\n" + nockCalls.join('\n'),
'utf8'
);
}
})().done();
() => fs.writeFile(outputFilePath, output.file.contents)
);