makhulu

🦁 Simple and parallel Node.js task runner
- Parallel, all functions are async
- Simple, no need to write plugins/wrappers, do everything in plain TypeScript / JavaScript
- Strongly typed, supports TypeScript out of the box
Installation
yarn add makhulu
A step-by-step example with comments
More examples at https://github.com/mgenware/makhulu-examples
Use terserjs to uglify all .js files in files
folder, and merge the results into one file and write it to dist/bundle.js
:
/** * Prerequisites: * Please install the required packages first: * `yarn add makhulu terser` */;; ;
Sample output:
🦁 Job started
> 2 item(s)
[
{ 'file.relative_file': 'a.js', 'file.src_dir': './files/' },
{ 'file.relative_file': 'sub/b.js', 'file.src_dir': './files/' }
]
> Done in 2ms
🦁 Source files
a.js
sub/b.js
[
{ 'file.relative_file': 'a.js', 'file.src_dir': './files/' },
{ 'file.relative_file': 'sub/b.js', 'file.src_dir': './files/' }
]
> Done in 2ms
🦁 Read files
[
{
'file.relative_file': 'a.js',
'file.src_dir': './files/',
'file.content': '<file contents>'
},
{
'file.relative_file': 'sub/b.js',
'file.src_dir': './files/',
'file.content': '<file contents>'
}
]
> Done in 3ms
🦁 Uglify
[
{
'file.relative_file': 'a.js',
'file.src_dir': './files/',
'file.content': '<file contents>'
},
{
'file.relative_file': 'sub/b.js',
'file.src_dir': './files/',
'file.content': '<file contents>'
}
]
> Done in 16ms
🦁 Merge files
> 2 --> 1 item(s)
[
{
'file.src_dir': './files/',
'file.relative_file': 'bundle.js',
'file.content': '<file contents>'
}
]
> Done in 1ms
🦁 Write files
[
{
'file.src_dir': './files/',
'file.relative_file': 'bundle.js',
'file.content': '<file contents>',
'file.dest_file': 'dist/bundle.js'
}
]
> Done in 4ms
🦁 Dest files
dist\bundle.js
[
{
'file.src_dir': './files/',
'file.relative_file': 'bundle.js',
'file.content': '<file contents>',
'file.dest_file': 'dist/bundle.js'
}
]
> Done in 7ms
Common Errors
File content not found on data object
This happens in writeToDirectory
when it gets a null
or undefined
when calling DataObject.get(FS.FileContent)
. Possible reasons:
- You forgot to call
readToString
, or calledreadToString
without theawait
keyword before callingwriteToDirectory
. - You accidentally set the data entry value to
null
orundefined
, if you want to write to an empty file, set it to an empty string (''
), or if you want to remove this file, useDataList.filter
orDataList.reset
instead.
Relative path not found on data object
writeToDirectory
cannot locate the source path of a file, you forgot to call fs.src
before writeToDirectory
?