Properly check if module, process or web
This commit is contained in:
parent
35b5c04f9b
commit
5d525c357d
|
@ -58,6 +58,9 @@ mscript.state_clear = function state_clear () {
|
||||||
};
|
};
|
||||||
mscript.interpret = function interpret (text, callback) {
|
mscript.interpret = function interpret (text, callback) {
|
||||||
mscript.state_clear();
|
mscript.state_clear();
|
||||||
|
if (typeof text === 'undefined') {
|
||||||
|
mscript.fail('No input');
|
||||||
|
}
|
||||||
var lines = text.split('\n'),
|
var lines = text.split('\n'),
|
||||||
two = '',
|
two = '',
|
||||||
arr = [],
|
arr = [],
|
||||||
|
@ -358,15 +361,18 @@ mscript.tests = function tests () {
|
||||||
console.timeEnd('Tests took');
|
console.timeEnd('Tests took');
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (!module.parent) {
|
||||||
fs = require('fs');
|
|
||||||
module.exports = mscript;
|
|
||||||
} else {
|
|
||||||
if (typeof process !== 'undefined') {
|
if (typeof process !== 'undefined') {
|
||||||
fs = require('fs');
|
fs = require('fs');
|
||||||
input = process.argv[2];
|
input = process.argv[2];
|
||||||
mscript.init();
|
mscript.init();
|
||||||
|
} else {
|
||||||
|
//web
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log('module here');
|
||||||
|
fs = require('fs');
|
||||||
|
module.exports = mscript;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue