Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
}
// diff old and new cursor node texts, with a special cursor
// symbol inserted to find out where it moves to
const oldCursorNodeCharArray = oldCursorNodeText.split("");
oldCursorNodeCharArray.splice(
cursorOffsetRelativeToOldCursorNode,
0,
CURSOR
);
const newCursorNodeCharArray = newCursorNodeText.split("");
const cursorNodeDiff = diff.diffArrays(
oldCursorNodeCharArray,
newCursorNodeCharArray
);
let cursorOffset = newCursorNodeStart;
for (const entry of cursorNodeDiff) {
if (entry.removed) {
if (entry.value.indexOf(CURSOR) > -1) {
break;
}
} else {
cursorOffset += entry.count;
}
}
return { formatted: result.formatted, cursorOffset };
function updateBrowserslist() {
console.log(chalk.whiteBright('Checking browserslist'));
console.log();
const data = browserslist.readConfig(BROWSERSLIST_PATH);
const production = browserslist(null, {
env: 'production-template',
config: BROWSERSLIST_PATH,
});
const d = diff.diffArrays(data.production, production);
d.forEach(part => {
// green for additions, red for deletions
// grey for common parts
if (part.added) {
console.log(chalk.green(part.value.join('\n')));
} else if (part.removed) {
console.log(chalk.red(part.value.join('\n')));
} else {
console.log(chalk.grey(part.value.join('\n')));
}
});
console.log();
const oldConfig = dumpConfig(data);
const newConfig = dumpConfig({...data, production});
if (oldConfig !== newConfig) {
export const matchedDepsDiffTable = (title1: string, title2: string, deps1: string[], deps2: string[]) => {
const depsDiff = diffArrays(deps1, deps2)
// Get deduplicated names (no version) of the changed deps.
const depNames = [
...new Set(
R.compose(
R.map(k => R.head(R.split('@', k))),
R.flatten,
R.pluck('value'),
R.filter((k: any) => !!k.removed || !!k.added)
)(depsDiff)
),
].sort()
const produceStartValues = () => R.map(_ => [])(depNames) as any
// Each of the following objects will start as a { `depName`: [] }, ... }-like.
const addedDeps = R.zipObj(depNames, produceStartValues())
const removedDeps = R.zipObj(depNames, produceStartValues())
function removeFilesFromDiff( base, from, to ) {
diffArrays( from, to ).forEach( d => {
if ( d.removed && d.value ) {
d.value.forEach( f => {
rimraf.sync( resolve( base, f ) );
} );
}
} );
}