write-if-changed
Install
npm i @writeifchanged/write-if-changed --save
Usage
Simple
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);
}
With Logging
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,
});
}