@writeifchanged/write-if-changed
v0.2.0
Published
Allows writing and copying files only if the destination file is different
Downloads
6
Readme
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,
});
}