Skip to content

Commit

Permalink
esm update - fixes for node v10
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkettner committed Apr 24, 2020
1 parent 52eb255 commit 67a08a0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
5 changes: 1 addition & 4 deletions gulpfile.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ gulp.task('mocha:node', (done) => {
const nyc = new NYC(require('./nyc.config.js'))

const mocha = new Mocha({
reporter: 'spec',
reporter: 'dot',
timeout: 15000
});

Expand All @@ -197,16 +197,13 @@ gulp.task('mocha:node', (done) => {
mocha.addFile(file);
});

nyc.addAllFiles();

// Run the tests.
const runner = mocha.run(fails => {
failures += fails;
});

runner.on('end', () => {
nyc.writeCoverageFile();
nyc.report();
done()
});

Expand Down
12 changes: 8 additions & 4 deletions lib/buildConfig.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ const parseURL = (source) => {
}
}

async function loadURL(url, fetchOpts) {
async function loadURL(url) {
console.log('-------------------')
console.log(parseURL(url))
console.log(!parseURL(url))
console.log('-------------------')
return fetch(url, fetchOpts).then(r => r.text().then(text => text))
}

const codeGen = (config) => {
let result = `import * as Modernizr from "../modernizr/src/Modernizr.js"\n`
let result = `import * as Modernizr from "./src/Modernizr.js"\n`

const detects = config['feature-detects'] || [];
const options = (config['options'] || []).filter(o => {
Expand All @@ -27,12 +31,12 @@ const codeGen = (config) => {
});

result += options.map(o => {
let optionPath = `../modernizr/src/${o}.js`;
let optionPath = `./src/${o}.js`;

return `import ${o} from "${optionPath}";`
}).join('\n')

result += detects.map(d => `import "${ d.replace(/^(test\/)?/,'../modernizr/feature-detects/') }.js";`).join('\n')
result += detects.map(d => `import "${ d.replace(/^(test\/)?/,'./feature-detects/') }.js";`).join('\n')

// if globalVar is undefined or is set but not a string or "false", set to Modernizr
if (config.globalVar === undefined || (typeof config.globalVar !== 'string' && config.globalVar !== false)) {
Expand Down
3 changes: 2 additions & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ function options(cb, allMetadata) {
.filter(function(doc) {
return doc && doc.length;
})
.flat(Infinity)
.reduce((acc, val) => acc.concat(val), [])
.reduce((acc, val) => acc.concat(val), [])

if (cb) {
cb(opts);
Expand Down
37 changes: 19 additions & 18 deletions test/universal/lib/buildQuery.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
var buildQuery
var expect = expect || undefined
var metadata
describe.skip('cli/buildQuery', function() {
var buildQuery
var expect
var metadata

if (typeof self === 'undefined') {
var root = require('find-parent-dir').sync(__dirname, 'package.json');
buildQuery = require(root + 'lib/buildQuery').default;
metadata = require(root + 'lib/metadata').default();
expect = require('chai').expect;
} else {
buildQuery = makeIIFE({file: "./lib/buildQuery.js", func: 'buildQuery'})
eval(buildQuery)
var _metadata = $.get({
url: '../lib/metadataStatic.js',
async: false
}).responseText;
eval(_metadata)
}
if (typeof self === 'undefined') {
var root = require('find-parent-dir').sync(__dirname, 'package.json');
buildQuery = require(root + 'lib/buildQuery').default;
metadata = require(root + 'lib/metadata').default();
expect = require('chai').expect;
} else {
expect = chai.expect
buildQuery = makeIIFE({file: "./lib/buildQuery.js", func: 'buildQuery'})
eval(buildQuery)
var _metadata = $.get({
url: '../lib/metadataStatic.js',
async: false
}).responseText;
eval(_metadata)
}

describe('cli/buildQuery', function() {

it('renames html5shiv and html5printshiv to shiv and printshiv', function() {
var shiv_query = buildQuery({'options': ['html5shiv']}, metadata)
Expand Down

0 comments on commit 67a08a0

Please sign in to comment.