index.js 763 B

12345678910111213141516171819202122
  1. var fs = require('fs')
  2. var br = require('../')
  3. var test = fs.readFileSync(require.resolve('uglify-js/test/run-tests.js'), 'utf8')
  4. .replace(/^#.*\n/, '')
  5. var transform = br(require.resolve('uglify-js'))
  6. transform.pipe(fs.createWriteStream(__dirname + '/output.js'))
  7. .on('close', function () {
  8. Function('module,require', test)({
  9. filename: require.resolve('uglify-js/test/run-tests.js')
  10. },
  11. function (name) {
  12. if (name === '../tools/node') {
  13. return require('./output.js')
  14. } else if (/^[a-z]+$/.test(name)) {
  15. return require(name)
  16. } else {
  17. throw new Error('I didn\'t expect you to require ' + name)
  18. }
  19. })
  20. })
  21. transform.end(fs.readFileSync(require.resolve('uglify-js'), 'utf8'))