diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c65648..3de6486 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.6.1 Maintenance release (2018-01-12) +* Updated dependencies + ## 0.6.0 Feature release (2018-08-04) * Updated dependencies * Include resource paths in result object diff --git a/index.js b/index.js index 02acc7e..a2e66fb 100755 --- a/index.js +++ b/index.js @@ -149,28 +149,26 @@ function shortbread(js, css, critical, slot, callback, config) { result.resources[resourceHash] = `${options.prefix}${jsFile.relative}`; result.initial += ``; result.subsequent += ``; - }) - ; + }); jsUrls.forEach((jsUrl) => { const resourceHash = shortbread.createHash(jsUrl); result.resources[resourceHash] = jsUrl; result.initial += ``; result.subsequent += ``; - }) - ; + }); // 3.a Critical CSS & JavaScript criticalFiles.forEach((criticalFile) => { // Detect whether it's a JavaScript resource for (const r of options.js -) { + ) { if (criticalFile.relative.match(r)) { result.initial += ``; return; } } - // Detect whether it's a CSS resource + // Detect whether it's a CSS resource for (const r of options.css) { if (criticalFile.relative.match(r)) { result.initial += ``; @@ -186,15 +184,13 @@ function shortbread(js, css, critical, slot, callback, config) { result.resources[resourceHash] = `${options.prefix}${cssFile.relative}`; result.initial += ``; synchronousCSS += ``; - }) - ; + }); cssUrls.forEach((cssUrl) => { const resourceHash = shortbread.createHash(cssUrl); result.resources[resourceHash] = cssUrl; result.initial += ``; synchronousCSS += ``; - }) - ; + }); if (synchronousCSS.length) { result.initial += ``; result.subsequent += synchronousCSS; diff --git a/package.json b/package.json index 3875cc8..0425157 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shortbread", - "version": "0.6.0", + "version": "0.6.1", "description": "Asynchronous, non-blocking loading pattern for CSS and JavaScript resources", "main": "index.js", "scripts": { @@ -8,7 +8,7 @@ "coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", "build": "babel lib --presets es2015-script --out-dir build", "prepublish": "npm run build", - "php": "npm run build && node test/php/php.js && php -S 0.0.0.0:8080 -t tmp" + "php": "npm run build && node test/php/php.js && php -S 0.0.0.0:80 -t tmp" }, "repository": { "type": "git", @@ -36,26 +36,27 @@ "homepage": "https://github.com/jkphl/shortbread#readme", "dependencies": { "crypto": "1.0.1", - "fg-loadcss": "^2.0.1", + "fg-loadcss": "^2.1.0", "is-url": "^1.2.4", - "through2": "^2.0.3", - "uglify-js": "^3.4.6", + "npm-check-updates": "^2.15.0", + "through2": "^3.0.0", + "uglify-js": "^3.4.9", "vinyl": "^2.2.0" }, "devDependencies": { - "babel-cli": "^6.24.1", + "babel-cli": "^6.26.0", "babel-preset-es2015-script": "^1.1.0", "coveralls": "^3.0.2", - "eslint": "^5.3.0", - "eslint-config-airbnb": "^17.0.0", - "eslint-plugin-import": "^2.13.0", - "eslint-plugin-jsx-a11y": "6.1.1", - "eslint-plugin-react": "^7.10.0", - "fs-extra": "^7.0.0", - "gulp": "^3.9.1", + "eslint": "^5.12.0", + "eslint-config-airbnb": "^17.1.0", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-jsx-a11y": "6.1.2", + "eslint-plugin-react": "^7.12.3", + "fs-extra": "^7.0.1", + "gulp": "^4.0.0", "gulp-filter": "^5.1.0", "gulp-template": "^5.0.0", - "handlebars": "^4.0.10", + "handlebars": "^4.0.12", "istanbul": "^0.4.5", "mocha": "^5.2.0", "mocha-lcov-reporter": "^1.3.0", diff --git a/test/main.js b/test/main.js index 8757741..afed3be 100755 --- a/test/main.js +++ b/test/main.js @@ -332,7 +332,7 @@ describe('shortbread().stream', () => { }); it('should set result data other resources', (done) => { - gulp.src(['fixtures/*.js', 'fixtures/style.css', 'gulp/gulp.php'], { cwd: __dirname }) + gulp.src(['fixtures/script.js', 'fixtures/style.css', 'gulp/gulp.php'], { cwd: __dirname }) .pipe(shortbread.stream()) .pipe(assert.length(3)) .pipe(assert.nth(0, (d) => { @@ -390,11 +390,12 @@ describe('shortbread().stream', () => { gulp.src(['fixtures/*', 'gulp/gulp.php'], { cwd: __dirname }) .pipe(shortbread.stream(null, null, null, { css: ['\\.scss$'], js: ['\\.jsx$'] })) - .pipe(assert.length(6)) + .pipe(assert.length(7)) .pipe(assert.nth(2, assertData)) .pipe(assert.nth(3, assertData)) .pipe(assert.nth(4, assertData)) .pipe(assert.nth(5, assertData)) + .pipe(assert.nth(6, assertData)) .pipe(assert.end(done)); }); @@ -425,7 +426,7 @@ describe('shortbread().stream', () => { }); it('data JSON file', (done) => { - gulp.src('none') + gulp.src('none', { allowEmpty: true }) .pipe(shortbread.stream(null, null, null, { data: true })) .pipe(assert.length(1)) .pipe(assert.nth(0, (d) => { @@ -444,7 +445,7 @@ describe('shortbread().stream', () => { it('external resources / URLs', (done) => { const resources = { jsUrl: [jsUrl], cssUrl: [cssUrl], data: true }; const resourceHash = shortbread.createHash(`${jsHash}-${jsUrlHash}-${cssHash}-${cssUrlHash}`); - gulp.src(['fixtures/*.js', 'fixtures/style.css', 'gulp/gulp.php'], { cwd: __dirname }) + gulp.src(['fixtures/script.js', 'fixtures/style.css', 'gulp/gulp.php'], { cwd: __dirname }) .pipe(shortbread.stream(null, null, null, resources)) .pipe(assert.length(4)) .pipe(assert.nth(3, (d) => { diff --git a/test/php/php.js b/test/php/php.js index 3cdc020..787622b 100755 --- a/test/php/php.js +++ b/test/php/php.js @@ -8,13 +8,15 @@ const handlebars = require('handlebars'); fs.mkdirsSync(path.join(__dirname, '../tmp')); const criticalCSS = vinyl.readSync(path.join(__dirname, '../fixtures/critical.css')); +const criticalJS = vinyl.readSync(path.join(__dirname, '../fixtures/critical.js')); +criticalJS.path = `${criticalJS.base}/index.php?asset=critical.js`; const script = vinyl.readSync(path.join(__dirname, '../fixtures/script.js')); script.path = `${script.base}/index.php?asset=script.js`; -const js = [script]; +const js = [criticalJS, script]; const style = vinyl.readSync(path.join(__dirname, '../fixtures/style.css')); style.path = `${style.base}/index.php?asset=style.css`; const css = [style]; -const result = shortbread(js, css, criticalCSS, 'main', 'allLoaded'); +const result = shortbread(js, css, [criticalCSS, criticalJS], 'main', 'allLoaded'); // Compile and store the PHP test file const hbs = fs.readFileSync(path.join(__dirname, 'index.hbs'));