@kokiito0926/pseudoalias 0.0.0 → 0.0.1

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 CHANGED
@@ -3,6 +3,21 @@
3
3
  スードーエイリアス(pseudoalias)を用いれば、擬似的なエイリアスを作成することができます。
4
4
  .bashrcなどにエイリアスを書くよりも、JavaScriptのファイルにエイリアスを書けたほうが便利かと思いました。
5
5
 
6
+ ## インストール
7
+
8
+ ```bash
9
+ $ npm install --global @kokiito0926/pseudoalias
10
+ ```
11
+
12
+ ## 実行方法
13
+
14
+ ```bash
15
+ $ pseudoalias --config ./example.js
16
+ $ pseudoalias --config ./example.js greetings
17
+ $ pseudoalias --config ./example.js addition 1 2
18
+ $ pseudoalias --config ./example.js subtraction 2 1
19
+ ```
20
+
6
21
  ## ライセンス
7
22
 
8
23
  [MIT](LICENSE)
package/example.js CHANGED
@@ -5,3 +5,15 @@ export const greetings = async () => {
5
5
  export const addition = async (one, two) => {
6
6
  console.log(Number(one) + Number(two));
7
7
  };
8
+
9
+ export const subtraction = async (one, two) => {
10
+ console.log(Number(one) - Number(two));
11
+ };
12
+
13
+ export const multiplication = async (one, two) => {
14
+ console.log(Number(one) * Number(two));
15
+ };
16
+
17
+ export const division = async (one, two) => {
18
+ console.log(Number(one) / Number(two));
19
+ };
package/index.js CHANGED
@@ -1,21 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // ホームディレクトリに設定のファイルを保存できるようにする。
4
+ // そのようにすれば、コマンドをより短くすることができると思う。
5
+ // そのような処理を実装するのであれば、os.homedir関数を用いればいいような気がする。
6
+ // >> 2026/01/27 18:33.
7
+
3
8
  // >> $ node ./index.js --config example.js
4
9
  // >> $ node ./index.js --config example.js greetings
5
10
  // >> $ node ./index.js --config example.js addition 1 2
6
11
 
7
- import { minimist, argv } from "zx";
12
+ import { minimist, path, argv } from "zx";
8
13
  import { pathToFileURL } from "node:url";
9
14
 
10
- // argv._.shift();
11
-
12
15
  const commands = argv._;
13
16
 
14
17
  const args = minimist(process.argv.slice(2));
15
18
  const config = args.config;
16
- // const config = argv.config;
17
19
  // console.log(argv);
18
- // console.log(commands, config);
20
+ // console.log(args);
19
21
  // process.exit(0);
20
22
 
21
23
  const targetFile = config;
@@ -23,9 +25,13 @@ if (!targetFile) {
23
25
  process.exit(0);
24
26
  }
25
27
 
26
- const targetPath = targetFile;
27
- // const targetPath = path.resolve(targetFile);
28
+ // const targetPath = targetFile;
29
+ const targetPath = path.resolve(targetFile);
30
+ if (!targetPath) {
31
+ process.exit(0);
32
+ }
28
33
  // console.log(targetPath);
34
+ // process.exit(0);
29
35
 
30
36
  try {
31
37
  const aliasModule = await import(pathToFileURL(targetPath).href);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokiito0926/pseudoalias",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "private": false,
5
5
  "description": "スードーエイリアス(pseudoalias)を用いれば、擬似的なエイリアスを作成することができます。",
6
6
  "keywords": [