1.0.14 • Published 2 years ago

wesp v1.0.14

Weekly downloads
-
License
GNU General Publi...
Repository
github
Last release
2 years ago

wesp

Execute actions on file changes.

Install

npm install wesp --save-dev

Setup

Create a wesp.js file:

// wesp.js
const wesp = require('wesp');

wesp.onLoad( () => console.log('Bzzz') );

Use

$ wesp

(if wesp has been installed globally npm install wesp -g, otherwise use ./node_modules/bin/wesp)

Result

[20:59:06] Starting...
Bzzz

To run once without continuing to watch files use:

$ wesp --continue-watching=false

By default wesp looks for a wesp.js file in the current directory. To use a different file use:

$ wesp /my/path/file.js

API

The following methods can be used in your wesp.js file to define your workflow:

// Watch for file changes (fire once per grouped changes)
wesp.onFileChange('myfolder/*.js', () => console.log('Bzzz') );

// Watch for file changes (fire for each changed and added file)
wesp.onSingleFileChange('myfolder/*.js', filePath => console.log('Bzzz', filePath) );

// Execute actions sequentially
wesp.onFileChange('myfolder/*.js', 
    series(
        callback => {console.log('Bzzz'); callback();},
        callback => {console.log('Bzzz'); callback();},
    )
);

// Execute actions simultaniously
wesp.onFileChange('myfolder/*.js', 
    parallel(
        callback => {console.log('Bzzz'); callback();},
        callback => {console.log('Bzzz'); callback();},
    )
);

// Execute action for all files
wesp.forEachFile(
    'myfolder/*.js', 
    (path, content) => callback => { console.log(path,content); callback();}
);

// Execute action only if one set of files is newer than other set of files
wesp.ifNewerThan(
    'myfolder/*.js',
    'otherfolder/*.txt', 
    callback => {console.log('Bzzz'); callback();} 
);
 
wesp.onFileChange('file1.txt', // Monitor for file changes
  series(
   read('file1.txt'), // Read file content
   pipe(content => content + ' hello world'), // Append ' hello world' to content
   read('file2.txt') // Write appended content to second file
  )
);
1.0.14

2 years ago

1.0.13

2 years ago

1.0.11

2 years ago

1.0.12

2 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago