shrinkwrap.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. /*!
  2. * Bootstrap Grunt task for generating npm-shrinkwrap.canonical.json
  3. * http://getbootstrap.com
  4. * Copyright 2014 Twitter, Inc.
  5. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  6. */
  7. /*
  8. This Grunt task updates the npm-shrinkwrap.canonical.json file that's used as the key for Bootstrap's npm packages cache.
  9. This task should be run and the updated file should be committed whenever Bootstrap's dependencies change.
  10. */
  11. 'use strict';
  12. var canonicallyJsonStringify = require('canonical-json');
  13. var NON_CANONICAL_FILE = 'npm-shrinkwrap.json';
  14. var DEST_FILE = 'test-infra/npm-shrinkwrap.canonical.json';
  15. function updateShrinkwrap(grunt) {
  16. // Assumption: Non-canonical shrinkwrap already generated by prerequisite Grunt task
  17. var shrinkwrapData = grunt.file.readJSON(NON_CANONICAL_FILE);
  18. grunt.log.writeln('Deleting ' + NON_CANONICAL_FILE.cyan + '...');
  19. grunt.file.delete(NON_CANONICAL_FILE);
  20. // Output as Canonical JSON in correct location
  21. grunt.file.write(DEST_FILE, canonicallyJsonStringify(shrinkwrapData));
  22. grunt.log.writeln('File ' + DEST_FILE.cyan + ' updated.');
  23. }
  24. module.exports = updateShrinkwrap;