Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

postinstall.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. var path = require("path"),
  3. fs = require("fs"),
  4. pkg = require(path.join(__dirname, "..", "package.json"));
  5. // ensure that there is a node_modules folder for cli dependencies
  6. try { fs.mkdirSync(path.join(__dirname, "..", "cli", "node_modules")); } catch (e) {/**/}
  7. // check version scheme used by dependents
  8. if (!pkg.versionScheme)
  9. return;
  10. var warn = process.stderr.isTTY
  11. ? "\x1b[30m\x1b[43mWARN\x1b[0m \x1b[35m" + path.basename(process.argv[1], ".js") + "\x1b[0m"
  12. : "WARN " + path.basename(process.argv[1], ".js");
  13. var basePkg;
  14. try {
  15. basePkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "package.json")));
  16. } catch (e) {
  17. return;
  18. }
  19. [
  20. "dependencies",
  21. "devDependencies",
  22. "optionalDependencies",
  23. "peerDependencies"
  24. ]
  25. .forEach(function(check) {
  26. var version = basePkg && basePkg[check] && basePkg[check][pkg.name];
  27. if (typeof version === "string" && version.charAt(0) !== pkg.versionScheme)
  28. process.stderr.write(pkg.name + " " + warn + " " + pkg.name + "@" + version + " is configured as a dependency of " + basePkg.name + ". use " + pkg.name + "@" + pkg.versionScheme + version.substring(1) + " instead for API compatibility.\n");
  29. });