4.0.0 • Published 4 years ago

is-changed v4.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

is-changed

Designed to track dependencies in package.json and check file modification time. Result is saved to local files, but not memory. Useful for task runners and builders, when you need to know is it necessary run rebuild someting.

CLI

Check dependencies in package.json, run command npm run build:libs if changes found. Snapshot will be stored in .libs.dat.

is-changed --dependencies -t .libs.dat -u "npm run build:libs"

Check file src/style.scss time modification, execute npm run build:style if time is different from latest saved snapshot to .style.dat.

is-changed -f src/style.scss -t .style.dat -u "npm run build:style"

API

changed.file({ targetFile: string, databaseFile?: string }): Result
type Result = {
    result: boolean; // is file modified
    update: () => void; // update filemtime
};
changed.dependenciesdependencies({ databaseFile?: string, cwd?: string }): Result
type Result = {
    result: boolean; // has changed
    update: () => void; // update filemtime
    initial: boolean; // indicates first run
    diff: Dict | null; // result difference
};
type Dict = { [name: string]: { $set: any, $was: any } };

EXAMPLES

const changed = require('is-changed');
const Path = require('path');
const buildPath = 'dist';

Example 1: File changed

const styleChanged = changed.file(`src/style.scss`, Path.resolve(buildPath, '.style.dat'));
// do something useful with src/style.scss...
styleChanged.update();

Example 2: Track dependencies

const libsChanged = changed.dependencies(Path.resolve(buildPath, '.libs.dat'));
// do something...
styleChanged.update();
4.0.0

4 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.2.0

5 years ago

2.1.6

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago