Skip to content
Permalink
Browse files

[js] Support for out load time dependency detecting CompUnit::Repo sc…

…heme
  • Loading branch information...
pmurias committed Oct 31, 2018
1 parent 9df074b commit 78389aa233ff19446b4adc2a655b8646173bbe5f
Showing with 27 additions and 8 deletions.
  1. +2 −1 src/vm/js/make-release.js
  2. +25 −7 src/vm/js/rakudo-library.js
@@ -74,6 +74,7 @@ fs.writeFileSync(path.join(releaseDir, 'package.json'), JSON.stringify({
"dependencies": {
"nqp-runtime": version,
"perl6-runtime": version,
"nqp-js-on-js": version
"nqp-js-on-js": version,
"tmp": "0.0.33"
}
}, null, 2));
@@ -1,3 +1,6 @@
const fs = require('fs');
const tmp = require('tmp');

const nqp = require('nqp-runtime');
const oldRun = nqp.run;

@@ -19,20 +22,35 @@ nqp.args = function(calledFrom) {

const code = require('./rakudo.js');


const core = require('nqp-runtime/core.js');

module.exports = function(source) {
passedArgs = ['perl6-js', '--target=js', source];
const tmpFile = tmp.tmpNameSync();

passedArgs = ['perl6-js', '--output', tmpFile, '--target=js', source];

const oldWritefh = nqp.op.getstdout().constructor.prototype.$$writefh;
let output;
const output = [];
nqp.op.getstdout().constructor.prototype.$$writefh = function(buf) {
output = core.toRawBuffer(buf).toString();
output.push(core.toRawBuffer(buf));
}

code();

nqp.op.getstdout().constructor.prototype.$$writefh = oldWritefh;
return output;
};
const lines = Buffer.concat(output).toString().split(/\n/);


const loaded = [];

for (const line of lines) {
let match;
if (/^[A-Z0-9]{40}\0/.test(line)) {
} else if (match = line.match(/^load-unit: (.+)/)) {
loaded.push(match[1]);
} else {
}
}


return {js: fs.readFileSync(tmpFile, 'utf8'), loaded: loaded};
};

0 comments on commit 78389aa

Please sign in to comment.
You can’t perform that action at this time.