Skip to content

Commit 7523c41

Browse files
TheDancingCoderoblarsen
authored andcommitted
Replace node-sri with ssri (#2031)
Closes #1997.
1 parent d6561f2 commit 7523c41

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

gulpfile.babel.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import runSequence from 'run-sequence';
1414
import archiver from 'archiver';
1515
import glob from 'glob';
1616
import del from 'del';
17-
import sri from 'node-sri';
17+
import ssri from 'ssri';
1818
import modernizr from 'modernizr';
1919

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

94-
gulp.task('copy:index.html', (done) =>
95-
sri.hash('node_modules/jquery/dist/jquery.min.js', (err, hash) => {
96-
if (err) throw err;
97-
98-
let version = pkg.devDependencies.jquery;
99-
let modernizrVersion = pkg.devDependencies.modernizr;
100-
gulp.src(`${dirs.src}/index.html`)
101-
.pipe(plugins().replace(/{{JQUERY_VERSION}}/g, version))
102-
.pipe(plugins().replace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
103-
.pipe(plugins().replace(/{{JQUERY_SRI_HASH}}/g, hash))
104-
.pipe(gulp.dest(dirs.dist));
105-
done();
106-
})
107-
);
94+
gulp.task('copy:index.html', () => {
95+
const hash = ssri.fromData(
96+
fs.readFileSync('node_modules/jquery/dist/jquery.min.js'),
97+
{ algorithms: ['sha256'] }
98+
);
99+
let version = pkg.devDependencies.jquery;
100+
let modernizrVersion = pkg.devDependencies.modernizr;
101+
102+
gulp.src(`${dirs.src}/index.html`)
103+
.pipe(plugins().replace(/{{JQUERY_VERSION}}/g, version))
104+
.pipe(plugins().replace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
105+
.pipe(plugins().replace(/{{JQUERY_SRI_HASH}}/g, hash.toString()))
106+
.pipe(gulp.dest(dirs.dist));
107+
});
108108

109109
gulp.task('copy:jquery', () =>
110110
gulp.src(['node_modules/jquery/dist/jquery.min.js'])

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"jshint-stylish": "^2.2.1",
2222
"mocha": "^5.0.1",
2323
"modernizr": "3.6.0",
24-
"node-sri": "^1.1.1",
2524
"normalize.css": "8.0.0",
2625
"run-sequence": "^2.2.1",
26+
"ssri": "^5.3.0",
2727
"strip-json-comments": "^2.0.1",
2828
"travis-after-all": "^1.4.5"
2929
},

0 commit comments

Comments
 (0)