Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace node-sri with ssri #2031

Merged
merged 1 commit into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import runSequence from 'run-sequence';
import archiver from 'archiver';
import glob from 'glob';
import del from 'del';
import sri from 'node-sri';
import ssri from 'ssri';
import modernizr from 'modernizr';

import pkg from './package.json';
Expand Down Expand Up @@ -91,20 +91,20 @@ gulp.task('copy:.htaccess', () =>
.pipe(gulp.dest(dirs.dist))
);

gulp.task('copy:index.html', (done) =>
sri.hash('node_modules/jquery/dist/jquery.min.js', (err, hash) => {
if (err) throw err;

let version = pkg.devDependencies.jquery;
let modernizrVersion = pkg.devDependencies.modernizr;
gulp.src(`${dirs.src}/index.html`)
.pipe(plugins().replace(/{{JQUERY_VERSION}}/g, version))
.pipe(plugins().replace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
.pipe(plugins().replace(/{{JQUERY_SRI_HASH}}/g, hash))
.pipe(gulp.dest(dirs.dist));
done();
})
);
gulp.task('copy:index.html', () => {
const hash = ssri.fromData(
fs.readFileSync('node_modules/jquery/dist/jquery.min.js'),
{ algorithms: ['sha256'] }
);
let version = pkg.devDependencies.jquery;
let modernizrVersion = pkg.devDependencies.modernizr;

gulp.src(`${dirs.src}/index.html`)
.pipe(plugins().replace(/{{JQUERY_VERSION}}/g, version))
.pipe(plugins().replace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
.pipe(plugins().replace(/{{JQUERY_SRI_HASH}}/g, hash.toString()))
.pipe(gulp.dest(dirs.dist));
});

gulp.task('copy:jquery', () =>
gulp.src(['node_modules/jquery/dist/jquery.min.js'])
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"jshint-stylish": "^2.2.1",
"mocha": "^5.0.1",
"modernizr": "3.6.0",
"node-sri": "^1.1.1",
"normalize.css": "8.0.0",
"run-sequence": "^2.2.1",
"ssri": "^5.3.0",
"strip-json-comments": "^2.0.1",
"travis-after-all": "^1.4.5"
},
Expand Down