@kokiito0926/hypernode 0.0.2 → 0.0.4
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 +21 -6
- package/example.js +13 -4
- package/import.js +15 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
## ハイパーノード(Hyper Node)
|
|
2
2
|
|
|
3
|
-
Node.js
|
|
4
|
-
[esm.sh](https://esm.sh/)
|
|
3
|
+
ハイパーノード(Hyper Node)は、Node.jsのカスタムローダーです。
|
|
4
|
+
HTTPS([esm.sh](https://esm.sh/)など)で公開されている、ESMのモジュールを直接的にimportをすることができるようになります。
|
|
5
|
+
[zx](https://github.com/google/zx)と組み合わせたりして、短いスクリプトを書いたりするときに便利かもしれません。
|
|
5
6
|
|
|
7
|
+
```javascript
|
|
8
|
+
import axios from "https://esm.sh/axios";
|
|
9
|
+
import { chunk } from "https://esm.sh/lodash";
|
|
10
|
+
|
|
11
|
+
console.log(axios?.get);
|
|
12
|
+
console.log(chunk([1, 2, 3, 4, 5, 6], 2));
|
|
6
13
|
```
|
|
14
|
+
|
|
15
|
+
## インストール
|
|
16
|
+
|
|
17
|
+
```bash
|
|
7
18
|
$ npm install --global @kokiito0926/hypernode
|
|
8
19
|
```
|
|
9
20
|
|
|
10
|
-
|
|
21
|
+
## 実行方法
|
|
22
|
+
|
|
23
|
+
```bash
|
|
11
24
|
$ hypernode ./example.js
|
|
12
25
|
```
|
|
13
26
|
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
## 未分類
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
$ node ./import.js ./example.js --message "Hello world!"
|
|
16
31
|
```
|
|
17
32
|
|
|
18
33
|
## ライセンス
|
|
19
34
|
|
|
20
|
-
MIT
|
|
35
|
+
[MIT](LICENSE)
|
package/example.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// >> $
|
|
3
|
+
// >> $ node ./import.js ./example.js --message "Hello world!"
|
|
4
4
|
|
|
5
5
|
// import { argv } from "zx";
|
|
6
|
-
import { argv } from "https://esm.sh/zx";
|
|
6
|
+
import { $, argv, minimist } from "https://esm.sh/zx";
|
|
7
7
|
|
|
8
8
|
import axios from "https://esm.sh/axios";
|
|
9
9
|
import { chunk } from "https://esm.sh/lodash";
|
|
10
10
|
|
|
11
11
|
// console.log("Hello world!");
|
|
12
12
|
|
|
13
|
+
console.log($);
|
|
14
|
+
|
|
13
15
|
console.log(argv);
|
|
14
16
|
console.log(argv?.message);
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
const args2 = minimist(process.argv.slice(2));
|
|
19
|
+
console.log(args2);
|
|
20
|
+
console.log(args2?.message);
|
|
21
|
+
|
|
22
|
+
// console.log(axios);
|
|
23
|
+
console.log(axios?.get);
|
|
24
|
+
|
|
17
25
|
console.log(chunk);
|
|
18
26
|
console.log(chunk([1, 2, 3, 4, 5, 6], 2));
|
|
27
|
+
|
|
19
28
|
process.exit(0);
|
package/import.js
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { argv } from "zx";
|
|
3
|
+
import { fs, path, argv } from "zx";
|
|
4
4
|
|
|
5
5
|
import { register } from "node:module";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
|
|
8
8
|
register("./hook.js", import.meta.url);
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// console.log(argv);
|
|
11
|
+
|
|
12
|
+
if (!argv._[0]) {
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const targetPath = path.resolve(process.cwd(), argv._[0]);
|
|
17
|
+
// const targetPath = path.resolve(process.cwd(), argv._[1]);
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(targetPath)) {
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
11
23
|
await import(pathToFileURL(targetPath).href);
|
|
12
24
|
// await import(argv._[1]);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kokiito0926/hypernode",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "ハイパーノード(Hyper Node)を用いると、importにHTTPSを指定することができるようになります。",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cli",
|
|
8
8
|
"bash",
|