deeper module loading
parent
9b72668cb1
commit
a0a6315e93
11
loader.mjs
11
loader.mjs
|
|
@ -3,6 +3,7 @@ import * as tsConfigPaths from "tsconfig-paths";
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import { dirname, resolve as pathResolve } from 'path';
|
import { dirname, resolve as pathResolve } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
import { sep } from 'path';
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
|
@ -38,8 +39,7 @@ export async function resolve(specifier, context, defaultResolver) {
|
||||||
'@commands:save': pathResolve(__dirname, 'src', 'commands', 'save.ts'),
|
'@commands:save': pathResolve(__dirname, 'src', 'commands', 'save.ts'),
|
||||||
'@commands:help': pathResolve(__dirname, 'src', 'commands', 'help.ts'),
|
'@commands:help': pathResolve(__dirname, 'src', 'commands', 'help.ts'),
|
||||||
|
|
||||||
'@builtin:systemd': pathResolve(__dirname, 'src', 'modules', 'systemd.ts'),
|
'@builtin:': (s) => pathResolve(__dirname, 'src', 'modules', s) + '.ts',
|
||||||
'@builtin:sshd': pathResolve(__dirname, 'src', 'modules', 'sshd.ts'),
|
|
||||||
|
|
||||||
'@echo off': pathResolve(__dirname, 'src', 'noop.ts')
|
'@echo off': pathResolve(__dirname, 'src', 'noop.ts')
|
||||||
};
|
};
|
||||||
|
|
@ -51,8 +51,11 @@ export async function resolve(specifier, context, defaultResolver) {
|
||||||
const match = matches[0];
|
const match = matches[0];
|
||||||
const replace = maps[match];
|
const replace = maps[match];
|
||||||
const len = match.length;
|
const len = match.length;
|
||||||
specifier = replace + specifier.substring(len)
|
specifier = specifier.substring(len);
|
||||||
|
if(typeof replace === 'string')
|
||||||
|
specifier = replace + specifier
|
||||||
|
else if (typeof replace === 'function')
|
||||||
|
specifier = replace(specifier);
|
||||||
} else if(matches.length > 1) {
|
} else if(matches.length > 1) {
|
||||||
const error = `Ambiguous import
|
const error = `Ambiguous import
|
||||||
specifier: ${specifier} matches:
|
specifier: ${specifier} matches:
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,5 @@ export default function() {
|
||||||
set v ...d : Set a kernel variable
|
set v ...d : Set a kernel variable
|
||||||
v : The name of the variable
|
v : The name of the variable
|
||||||
...d : The value (or values, space delimited)
|
...d : The value (or values, space delimited)
|
||||||
|
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
@ -132,4 +132,4 @@ const executor = createExecutor(kernel);
|
||||||
});
|
});
|
||||||
|
|
||||||
checkpoint('Kernel Loaded');
|
checkpoint('Kernel Loaded');
|
||||||
// import '@echo off';
|
import '@echo off';
|
||||||
Loading…
Reference in New Issue