UNPKG

parallel-uglifyjs

Version:

Recursively trawls a directory for .js files to uglify, running one node instance per available CPU.

34 lines (24 loc) 769 B
#!/usr/bin/node var job = require( './uglify-single.js' ).uglify; var id = process.argv[2]; const DEBUG = false; if ( DEBUG ) { console.log( 'worker' + id + ' started' ); } // Get things started process.send({ message: 'give_me_another' }); // node note: process.send sends to the master process if we were forked by // child_process (we have an IPC channel) process.on( 'message', function( msg ) { if ( 'go' == msg.cmd ) { job( msg.name, function () { process.send({ message: 'give_me_another' }); }); } else console.log( 'worker' + id + ': received unknown command: ' + msg.cmd ); }); process.on( 'exit', function( err ) { if ( DEBUG ) { console.log( 'worker' + id + ': I am exiting' ); } });