post_install.js 626 B

12345678910111213141516171819202122232425262728293031
  1. /* eslint-disable */
  2. // adapted based on rackt/history (MIT)
  3. // Node 0.10+
  4. var execSync = require('child_process').execSync;
  5. var fs = require('fs');
  6. // Node 0.10 check
  7. if (!execSync) {
  8. execSync = require('sync-exec');
  9. }
  10. function exec(command) {
  11. execSync(command, {
  12. stdio: [0, 1, 2]
  13. });
  14. }
  15. fs.stat('dist', function(error, stat) {
  16. // Skip building on Travis
  17. if (process.env.TRAVIS) {
  18. return;
  19. }
  20. if (error || !stat.isDirectory()) {
  21. // Create a directory to avoid getting stuck
  22. // in postinstall loop
  23. fs.mkdirSync('dist');
  24. exec('npm install --only=dev');
  25. exec('npm run build');
  26. }
  27. });