Skip to content

Commit

Permalink
fixed window is not defined when load editor from bash
Browse files Browse the repository at this point in the history
  • Loading branch information
2youyou2 committed Oct 20, 2017
1 parent dc7ae7f commit 93910fb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,17 @@
/**
* @property {Boolean} CC_TEST - Running in the engine's unit test.
*/
var _global = typeof window === 'undefined' ? global : window;
function defineMacro (name, defaultValue) {
// if "global_defs" not preprocessed by uglify, just declare them globally,
// this may happened in release version's preview page.
// (use evaled code to prevent mangle by uglify)
if (typeof window[name] == 'undefined') {
window[name] = defaultValue;
if (typeof _global[name] == 'undefined') {
_global[name] = defaultValue;
}
}
function defined (name) {
return typeof window[name] == 'object';
return typeof _global[name] == 'object';
}

defineMacro('CC_TEST', defined('tap') || defined('QUnit'));
Expand Down

0 comments on commit 93910fb

Please sign in to comment.