Allows writing and copying files only if the destination file is different
npm install @writeifchanged/write-if-changed
!Coverage
``sh`
npm i @writeifchanged/write-if-changed --save
`typescript
import { writeIfChanged } from '@writeifchanged/write-if-changed';
import * as path from 'path';
async function asyncTask(cb) {
const contents = JSON.stringify({ foo: 'bar', hello: 3, testName });
const dest = path.join(__dirname, 'some-folder', 'foo.json');
const result = await writeIfChanged(dest, contents);
}
`
`typescript
import { writeIfChanged } from '@writeifchanged/write-if-changed';
import * as path from 'path';
async function asyncTask(cb) {
const contents = JSON.stringify({ foo: 'bar', hello: 3, testName });
const dest = path.join(__dirname, 'some-folder', 'foo.json');
const result = await writeIfChanged(dest, contents, {
logger: ColoredConsoleLogger,
});
}
``