mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-14 18:42:30 +03:00
Switch to uber/npm-shrinkwrap for npm-shrinkwrap.json generation
Instead of our homegrown grunt/shrinkwrap.js Fixes #13483. New npm-shrinkwrap.json is human-readable but still in a consistent/stable format. Should aid debugging, produce better diffs, and be less prone to merge conflicts
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
/*!
|
||||
* Bootstrap Grunt task for generating npm-shrinkwrap.canonical.json
|
||||
* http://getbootstrap.com
|
||||
* Copyright 2014 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
*/
|
||||
/*
|
||||
This Grunt task updates the npm-shrinkwrap.canonical.json file that's used as the key for Bootstrap's npm packages cache.
|
||||
This task should be run and the updated file should be committed whenever Bootstrap's dependencies change.
|
||||
*/
|
||||
'use strict';
|
||||
var canonicallyJsonStringify = require('canonical-json');
|
||||
var NON_CANONICAL_FILE = 'npm-shrinkwrap.json';
|
||||
var DEST_FILE = 'test-infra/npm-shrinkwrap.canonical.json';
|
||||
|
||||
|
||||
function cleanup(shrinkwrap) {
|
||||
// Remove `resolved` property to avoid irrelevant changes
|
||||
// See https://github.com/npm/npm/issues/3581
|
||||
if (typeof shrinkwrap === 'string') {
|
||||
return shrinkwrap;
|
||||
}
|
||||
delete shrinkwrap.resolved;
|
||||
for (var key in shrinkwrap) {
|
||||
shrinkwrap[key] = cleanup(shrinkwrap[key]);
|
||||
}
|
||||
return shrinkwrap;
|
||||
}
|
||||
|
||||
function updateShrinkwrap(grunt) {
|
||||
// Assumption: Non-canonical shrinkwrap already generated by prerequisite Grunt task
|
||||
var shrinkwrapData = grunt.file.readJSON(NON_CANONICAL_FILE);
|
||||
grunt.log.writeln('Deleting ' + NON_CANONICAL_FILE.cyan + '...');
|
||||
grunt.file.delete(NON_CANONICAL_FILE);
|
||||
// Output as Canonical JSON in correct location
|
||||
grunt.file.write(DEST_FILE, canonicallyJsonStringify(cleanup(shrinkwrapData)));
|
||||
grunt.log.writeln('File ' + DEST_FILE.cyan + ' updated.');
|
||||
}
|
||||
|
||||
|
||||
module.exports = updateShrinkwrap;
|
||||
Reference in New Issue
Block a user