Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function(path1, path2, options, callback) {
// Required
options.compareSize = true;
options.compareContent = true;
// Git does not copy across datestamps but would be nice
// options.compareDate = true;
dircompare
.compare(path1, path2, options)
.then(function(res) {
if (!res.differences) return callback();
var message = [
path1 + "<>" + path2 + " has " + res.differences + " differences"
];
res.diffSet.forEach(function(entry) {
if (entry.state === "equal") return;
var state = {
left: "->",
right: "<-",
distinct: "<>"
}[entry.state];
juice_diff.prototype.diff = function (path1, path2) {
var store_compare_result
return dircompare.compare(path1, path2)
.then((compare_result) => {
store_compare_result = compare_result
// filter out ds_store files
_.remove(compare_result.diffSet, function (file) {
return (file.name1 == '.DS_Store' || file.name2 == '.DS_Store')
})
var abstract_cms_files = []
compare_result.diffSet.forEach((item) => {
abstract_cms_files.push(abstract_diff_item(item))
})
return Promise.all(abstract_cms_files)
})
sourceFile: `${reference.refDir}/swagger.${reference.swaggerFileExt}`,
outputPath: reference.genDir,
skipModuleExport: reference.skipIndex,
splitPathTags: reference.tags ? reference.tags.split(',') : []
})
.catch((err: Error) => console.error(`Error has occurred while generating api client for ${reference.name}`, err));
const {
same,
equal,
distinct,
differences,
left,
right,
diffSet,
} = await compare(`${reference.refDir}/api`, reference.genDir, COMPARE_OPTIONS);
if (!same) {
let result = ' Output should be the same, but there are differences.\n\n';
result += `differences: ${differences}\n\n`;
result += `equal: ${equal}\n`;
result += `distinct: ${distinct}\n`;
result += `left: ${left}\n`;
result += `right: ${right}\n`;
result += '[ reference dir ] [ test dir ]\n';
diffSet.forEach(({name1, name2, state, type1, type2}: DiffSet) => {
if (stateSymbols[state] !== stateSymbols.equal) {
result += `(${type1}) ${name1} ${stateSymbols[state]} ${name2} (${type2})\n`;
}
});
const testReturnValues = await Promise.all(testReferences.map(async (reference) => {
console.info(`Running test for ${reference.name}`);
const refDir = `${__dirname}/../tests/${reference.name}`;
const genDir = `${testsOutDir}/${reference.name}`;
await generateAPIClient({
sourceFile: `${refDir}/swagger.${reference.swaggerFileExt}`,
outputPath: genDir,
skipModuleExport: reference.skipIndex,
splitPathTags: reference.tags ? reference.tags.split(',') : []
})
.catch((err: Error) => console.error(`Error has occurred while generating api client for ${reference.name}`, err));
const {same, equal, distinct, differences, left, right, diffSet} = await compare(`${refDir}/api`, genDir, compareOptions);
if (!same) {
console.info(Colors.Red, `Test for ${reference.name} has failed\n`, Colors.Reset);
console.group(`Stats for ${reference.name}`);
console.info(`equal: ${equal}`);
console.info(`distinct: ${distinct}`);
console.info(`left: ${left}`);
console.info(`right: ${right}`);
console.info(`differences: ${differences}\n`);
console.info('[ reference dir ] [ test dir ]');
diffSet.forEach(({name1, name2, state, type1, type2}: DiffSet) => {
if (stateSymbols[state] !== stateSymbols.equal) {
console.info(`(${type1}) ${name1} ${stateSymbols[state]} ${name2} (${type2})`);
}
});
test('should generate the expected default result', async t => {
const stats = await webpack(baseWebpackConfig(new WebappWebpackPlugin({
logo: LOGO
})));
const outputPath = stats.compilation.compiler.outputPath;
const expected = path.resolve(FIXTURES, 'expected/default');
const compareResult = await dircompare.compare(outputPath, expected, compareOptions);
const diff = compareResult.diffSet.filter(({state}) => state !== 'equal').map(({name1, name2}) => `${name1} ≠${name2}`);
t.deepEqual(diff, []);
});
module.exports.compare = (a, b) => dircompare.compare(a, b, { compareContent: true, excludeFilter: '*.js' }).then(diff =>
diff.diffSet.filter(({ state }) => state !== 'equal')
.map(({ path1, name1, path2, name2 }) => `${path.join(path1 || '', name1 + '')} ≠${path.join(path2 || '', name2 + '')}`)
);
return Promise.all(packageInfo.packageJson.files.map(function (filesContainer) {
var localInstallFilesPath = path.join(packageCtx.localInstallPackagePath, filesContainer);
var localPublishFilesPath = path.join(packageCtx.packageLocalPublishRootPath, filesContainer);
return dircompare.compare(localInstallFilesPath, localPublishFilesPath, {
compareSize: true,
});
})).then(function (dircompareResults) {
var diffs = [];
const compare = (src, dest, excludeFilter = _excludeFilter) => () => {
dest = path.join(workingCwd, dest)
src = api.cwd(src)
if (!fs.existsSync(dest)) {
shell.mkdir('-p', path.join(dest, '..'))
shell.cp('-r', src, dest)
return Promise.resolve(true)
} else {
return dirCompare
.compare(src, dest, {
compareDate: false,
dateTolerance: 500000,
compareContent: true,
})
.then((resp = { diffSet: [] }) => {
const { diffSet } = resp
for (const diff of diffSet) {
if (!diff.name2 && !excludeFilter(diff)) {
assert(
false,
`${diff.relativePath} is missing ${diff.name1} in ${dest}`
)
}
const nf = `${diff.path1}/${diff.name1}`