@interaktiv/dia-scripts
Version:
CLI toolbox with common scripts for most sort of projects at DIA
26 lines (21 loc) • 639 B
JavaScript
import slash from 'slash';
// This removes the quotes around strings...
export const unquoteSerializer = {
print: val => val,
test: val => typeof val === 'string',
};
// This converts windows style file paths to unix...
export const winPathSerializer = {
print: val => slash(val),
test: val => typeof val === 'string' && val.includes('\\'),
};
function normalizePaths(value) {
if (typeof value !== 'string') {
return value;
}
return slash(value.split(process.cwd()).join('<PROJECT_ROOT>'));
}
export const relativePathSerializer = {
print: val => normalizePaths(val),
test: val => normalizePaths(val) !== val,
};