build.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. var MetaScript = require("metascript"),
  2. path = require("path"),
  3. fs = require("fs");
  4. var rootDir = path.join(__dirname, ".."),
  5. srcDir = path.join(rootDir, "src"),
  6. distDir = path.join(rootDir, "dist"),
  7. pkg = require(path.join(rootDir, "package.json")),
  8. filename;
  9. var scope = {
  10. VERSION: pkg.version,
  11. ISAAC: false
  12. };
  13. // Make standard build
  14. console.log("Building bcrypt.js with scope", JSON.stringify(scope, null, 2));
  15. fs.writeFileSync(
  16. path.join(distDir, "bcrypt.js"),
  17. MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope, srcDir)
  18. );
  19. // Make isaac build - see: https://github.com/dcodeIO/bcrypt.js/issues/16
  20. /* scope.ISAAC = true;
  21. console.log("Building bcrypt-isaac.js with scope", JSON.stringify(scope, null, 2));
  22. fs.writeFileSync(
  23. path.join(distDir, "bcrypt-isaac.js"),
  24. MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "bcrypt.js")), filename, scope, srcDir)
  25. ); */
  26. // Update bower.json
  27. scope = { VERSION: pkg.version };
  28. console.log("Updating bower.json with scope", JSON.stringify(scope, null, 2));
  29. fs.writeFileSync(
  30. path.join(rootDir, "bower.json"),
  31. MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "bower.json")), filename, scope, srcDir)
  32. );