Skip to content

Commit

Permalink
make it illegal to include imvu.js twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Austin committed Oct 24, 2014
1 parent 6c5c3ba commit 2b86a48
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SetOption('num_jobs', multiprocessing.cpu_count())
print "running with -j", GetOption('num_jobs')

FIRST_SOURCES = [
'src/includeguard.js',
'src/polyfill.js',
'third-party/es5-shim/es5-shim.js',
'third-party/es5-shim/es5-sham.js',
Expand Down
7 changes: 7 additions & 0 deletions src/includeguard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*global __included_imvujs__:true*/
(function() {
if (typeof __included_imvujs__ !== "undefined" && __included_imvujs__) {
throw EvalError("Do not include imvu.js twice.");
}
__included_imvujs__ = true;
})();
2 changes: 2 additions & 0 deletions tests/publicAPI.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
'__filename',
'__dirname',

'__included_imvujs__',

// browser-ish symbols prevented in tests
'requestAnimationFrame',

Expand Down

0 comments on commit 2b86a48

Please sign in to comment.