Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80635 views
1
/*
2
Copyright 2013 Daniel Wirtz <[email protected]>
3
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
8
http://www.apache.org/licenses/LICENSE-2.0
9
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16
17
/**
18
* node-harmonize (c) 2013 Daniel Wirtz <[email protected]>
19
* Released under the Apache License, Version 2.0
20
* see: https://github.com/dcodeIO/node-harmonize for details
21
*/
22
var child_process = require("child_process");
23
var isIojs = require("is-iojs");
24
25
module.exports = function() {
26
if (typeof Proxy == 'undefined') { // We take direct proxies as our marker
27
var v = process.versions.node.split(".");
28
29
if (!isIojs && v[0] == 0 && v[1] < 8) {
30
throw("harmonize requires at least node v0.8");
31
}
32
33
// harmony flag is unnecessary in io and beginning with node v0.12
34
if(isIojs || (!isIojs && v[0] == 0 && v[1] > 12)) {
35
return;
36
}
37
38
var node = child_process.spawn(process.argv[0], ['--harmony', '--harmony-proxies'].concat(process.argv.slice(1)), { stdio: 'inherit' });
39
node.on("close", function(code) {
40
process.exit(code);
41
});
42
43
// Interrupt process flow in the parent
44
process.once("uncaughtException", function(e) {});
45
throw("harmony");
46
}
47
};
48
49
// Usage: require("harmonize")();
50
51