0.2.0 • Published 3 years ago

@writeifchanged/write-if-changed v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

write-if-changed

npm Coverage

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,
	});
}