inspect dependencies, rewrite paths inside init
This commit is contained in:
parent
61ad82be61
commit
c73ee59d53
1 changed files with 18 additions and 5 deletions
23
app.js
23
app.js
|
|
@ -45,6 +45,24 @@ function init(mod) {
|
|||
|
||||
cacheDir = mod.util.datadir("cache");
|
||||
|
||||
// process script dependencies, expand paths
|
||||
for (let [key,val] of Object.entries(script)) {
|
||||
for (let path of val) {
|
||||
if (path.charAt(0) === '@') {
|
||||
continue;
|
||||
}
|
||||
let lines = fs.readFileSync(`${dir}/src/${path}.js`).toString().split('\n');
|
||||
for (let line of lines) {
|
||||
let dpos = line.indexOf('// dep:');
|
||||
if (dpos >= 0) {
|
||||
let dep = line.substring(dpos+7).trim();
|
||||
console.log({path, dep});
|
||||
}
|
||||
}
|
||||
}
|
||||
script[key] = val.map(p => p.charAt(0) !== '@' ? `src/${p}.js` : p);
|
||||
}
|
||||
|
||||
mod.on.test((req) => {
|
||||
let cookie = cookieValue(req.headers.cookie, "version") || undefined;
|
||||
let vmatch = mod.meta.version || "*";
|
||||
|
|
@ -464,11 +482,6 @@ const script = {
|
|||
]
|
||||
};
|
||||
|
||||
// process script dependencies, expand paths
|
||||
for (let [key,val] of Object.entries(script)) {
|
||||
script[key] = val.map(p => p.charAt(0) !== '@' ? `src/${p}.js` : p);
|
||||
}
|
||||
|
||||
// prevent caching of specified modules
|
||||
const cachever = {};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue