prepublish.js 627 B

123456789101112131415161718192021
  1. #!/usr/bin/env node
  2. var spawn = require('child_process').spawn;
  3. var fs = require('fs');
  4. var concat = require('concat-stream');
  5. var path = require('path');
  6. var uglify = spawn(
  7. require.resolve('uglify-js/bin/uglifyjs'),
  8. ['--wrap-iife', '-c', 'side_effects=false,screw_ie8=false', '--verbose', '--ie8', '--passes=5', '-m', '--source-map', '--', '-']
  9. );
  10. fs.createReadStream(path.join(__dirname, '..', 'prelude.js'))
  11. .pipe(uglify.stdin)
  12. ;
  13. uglify.stdout
  14. .pipe(concat({ encoding: 'string' }, function (str) {
  15. fs.writeFileSync(path.join(__dirname, '..', '_prelude.js'), str.replace(/;\s*$/, ''));
  16. }))
  17. ;