@kokiito0926/hypernode 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/example.js +18 -0
- package/hook.js +22 -0
- package/import.js +12 -0
- package/package.json +33 -0
package/README.md
ADDED
package/example.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env zx
|
|
2
|
+
|
|
3
|
+
// >> $ zx ./import.js ./example.js --message "Hello world!"
|
|
4
|
+
|
|
5
|
+
import { argv } from "zx";
|
|
6
|
+
|
|
7
|
+
import axios from "https://esm.sh/axios";
|
|
8
|
+
import { chunk } from "https://esm.sh/lodash";
|
|
9
|
+
|
|
10
|
+
console.log("Hello world!");
|
|
11
|
+
|
|
12
|
+
console.log(argv);
|
|
13
|
+
console.log(argv?.message);
|
|
14
|
+
|
|
15
|
+
console.log(axios);
|
|
16
|
+
console.log(chunk);
|
|
17
|
+
console.log(chunk([1, 2, 3, 4, 5, 6], 2));
|
|
18
|
+
process.exit(0);
|
package/hook.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { get } from "node:https";
|
|
2
|
+
|
|
3
|
+
export function load(url, context, nextLoad) {
|
|
4
|
+
if (url.startsWith("https://")) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
get(url, (res) => {
|
|
7
|
+
let data = "";
|
|
8
|
+
res.setEncoding("utf8");
|
|
9
|
+
res.on("data", (chunk) => (data += chunk));
|
|
10
|
+
res.on("end", () =>
|
|
11
|
+
resolve({
|
|
12
|
+
format: "module",
|
|
13
|
+
shortCircuit: true,
|
|
14
|
+
source: data,
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
17
|
+
}).on("error", (err) => reject(err));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return nextLoad(url);
|
|
22
|
+
}
|
package/import.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env zx
|
|
2
|
+
|
|
3
|
+
import { argv } from "zx";
|
|
4
|
+
|
|
5
|
+
import { register } from "node:module";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
|
|
8
|
+
register("./hook.js", import.meta.url);
|
|
9
|
+
|
|
10
|
+
const targetPath = path.resolve(process.cwd(), argv._[1]);
|
|
11
|
+
await import(pathToFileURL(targetPath).href);
|
|
12
|
+
// await import(argv._[1]);
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kokiito0926/hypernode",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "A hypernode project",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"homepage": "https://github.com/kokiito0926/",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"hypernode": "import.js"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/kokiito0926/hypernode/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/kokiito0926/hypernode.git"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "Koki Ito <kokiito0926@gmail.com>",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "node --test"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"zx": "^8.8.4"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=24.0.0"
|
|
32
|
+
}
|
|
33
|
+
}
|