Skip to content

Commit

Permalink
Merge pull request #2175 from sinonjs/upgrade-nise-and-browserify
Browse files Browse the repository at this point in the history
Upgrade nise and browserify
  • Loading branch information
mantoni committed Dec 19, 2019
2 parents 673c3f1 + d6ba8ae commit 6438640
Show file tree
Hide file tree
Showing 14 changed files with 2,009 additions and 3,075 deletions.
56 changes: 37 additions & 19 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,47 @@ makeBundle(
// Add inline source maps to the default bundle
debug: true,
// Create a UMD wrapper and install the "sinon" global:
standalone: "sinon"
standalone: "sinon",
// Do not detect and insert globals:
detectGlobals: false
},
function(bundle) {
var script = preamble + bundle;
fs.writeFileSync("pkg/sinon.js", script);
}
);

makeBundle("./lib/sinon.js", {}, function(bundle) {
var script = preamble + bundle;
fs.writeFileSync("pkg/sinon-no-sourcemaps.js", script);
});

makeBundle("./lib/sinon-esm.js", {}, function(bundle) {
var intro = "let sinon;";
var outro =
"\nexport default sinon;\n" +
Object.keys(sinon)
.map(function(key) {
return "const _" + key + " = sinon." + key + ";\nexport { _" + key + " as " + key + " };";
})
.join("\n");

var script = preamble + intro + bundle + outro;
fs.writeFileSync("pkg/sinon-esm.js", script);
});
makeBundle(
"./lib/sinon.js",
{
// Create a UMD wrapper and install the "sinon" global:
standalone: "sinon",
// Do not detect and insert globals:
detectGlobals: false
},
function(bundle) {
var script = preamble + bundle;
fs.writeFileSync("pkg/sinon-no-sourcemaps.js", script);
}
);

makeBundle(
"./lib/sinon-esm.js",
{
// Do not detect and insert globals:
detectGlobals: false
},
function(bundle) {
var intro = "let sinon;";
var outro =
"\nexport default sinon;\n" +
Object.keys(sinon)
.map(function(key) {
return "const _" + key + " = sinon." + key + ";\nexport { _" + key + " as " + key + " };";
})
.join("\n");

var script = preamble + intro + bundle + outro;
fs.writeFileSync("pkg/sinon-esm.js", script);
}
);
3 changes: 2 additions & 1 deletion lib/sinon/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var orderByFirstCall = require("@sinonjs/commons").orderByFirstCall;
var timesInWords = require("./util/core/times-in-words");
var format = require("./util/core/format");
var stringSlice = require("@sinonjs/commons").prototypes.string.slice;
var globalObject = require("@sinonjs/commons").global;

var arraySlice = arrayProto.slice;
var concat = arrayProto.concat;
Expand Down Expand Up @@ -60,7 +61,7 @@ function verifyIsValidAssertion(assertionMethod, assertionArgs) {
}

function failAssertion(object, msg) {
var obj = object || global;
var obj = object || globalObject;
var failMethod = obj.fail || assert.fail;
failMethod.call(obj, msg);
}
Expand Down
6 changes: 2 additions & 4 deletions lib/sinon/util/core/next-tick.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"use strict";

var globalObject = require("@sinonjs/commons").global;
var getNextTick = require("./get-next-tick");

/* istanbul ignore next */
var root = typeof window !== "undefined" ? window : global;

module.exports = getNextTick(root.process, root.setImmediate);
module.exports = getNextTick(globalObject.process, globalObject.setImmediate);
3 changes: 2 additions & 1 deletion lib/sinon/util/fake-timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var extend = require("./core/extend");
var llx = require("lolex");
var globalObject = require("@sinonjs/commons").global;

function createClock(config, globalCtx) {
var llxCtx = llx;
Expand All @@ -14,7 +15,7 @@ function createClock(config, globalCtx) {
}

function addIfDefined(obj, globalPropName) {
var globalProp = global[globalPropName];
var globalProp = globalObject[globalPropName];
if (typeof globalProp !== "undefined") {
obj[globalPropName] = globalProp;
}
Expand Down

0 comments on commit 6438640

Please sign in to comment.