Skip to content

Commit

Permalink
fix:shebang line issue
Browse files Browse the repository at this point in the history
  • Loading branch information
FADHILI-Josue committed May 11, 2024
1 parent 0916a3f commit 015142f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 47 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Retrieve saved WiFi passwords across Linux, Windows, and macOS systems.",
"type": "module",
"private": false,
"main": "./dist/bin.js",
"bin": {
"wifikeys": "./dist/bin.js"
},
Expand All @@ -12,7 +13,7 @@
],
"author": "FADHILI Josue <[email protected]>",
"scripts": {
"build": "echo #!/usr/bin/env node >> dist/bin.js && esbuild --bundle src/bin.ts --platform=node --outfile=dist/bin.js --packages=external --format=esm",
"build": "esbuild --bundle src/bin.ts --platform=node --outfile=dist/bin.js --packages=external --format=esm",
"dev": "run-p dev:*",
"dev:tsc": "tsc --watch --preserveWatchOutput",
"dev:node": "node --watch dist/bin.js",
Expand Down
47 changes: 2 additions & 45 deletions src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,5 @@
// #!/usr/bin/env node
#!/usr/bin/env node

import {Command} from 'commander';
import consola from 'consola';
import pkg from '../package.json';
import getWifiPassword from './utils/wifi-password';

const program = new Command();

program
.name('wifikeys')
.description('get wifi keys(passwords) CLI')
.usage('command [arguments]')
.version(
`\u001B[1mv${pkg.version}\u001B[0m`,
'-v, --version',
"Output wifikeys's current version.",
)
.helpOption('-h, --help', 'Output usage of wifikeys.');

program
.command('get [ssid]')
.description('get password for wifi')
.option('-n, --networks <networks...>', 'wifi networks to get passwords for')
.action(async (ssid: string, options) => {
try {
if (options?.networks?.length) {
const promises = (options.networks as string[]).map(async (ssid) => {
const password: string = await getWifiPassword(ssid);
console.log(`> ${ssid}: ${password} \n`);
});

// Wait for all promises to resolve
await Promise.all(promises);
process.exit(0);
}

await getWifiPassword(ssid).then(console.log);
process.exit(0);
} catch {
consola.error(
'failed to get password!! check if the you have saved password for wifi network',
);
process.exit(0);
}
});
import { program } from "./command";

program.parse(process.argv);
44 changes: 44 additions & 0 deletions src/command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {Command} from 'commander';
import consola from 'consola';
import pkg from '../package.json';
import getWifiPassword from './utils/wifi-password';

export const program = new Command();

program
.name('wifikeys')
.description('get wifi keys(passwords) CLI')
.usage('command [arguments]')
.version(
`\u001B[1mv${pkg.version}\u001B[0m`,
'-v, --version',
"Output wifikeys's current version.",
)
.helpOption('-h, --help', 'Output usage of wifikeys.');

program
.command('get [ssid]')
.description('get password for wifi')
.option('-n, --networks <networks...>', 'wifi networks to get passwords for')
.action(async (ssid: string, options) => {
try {
if (options?.networks?.length) {
const promises = (options.networks as string[]).map(async (ssid) => {
const password: string = await getWifiPassword(ssid);
console.log(`> ${ssid}: ${password} \n`);
});

// Wait for all promises to resolve
await Promise.all(promises);
process.exit(0);
}

await getWifiPassword(ssid).then(console.log);
process.exit(0);
} catch {
consola.error(
'failed to get password!! check if the you have saved password for wifi network',
);
process.exit(0);
}
});
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"strict": true, /* Enable all strict type-checking options. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
"noEmit": true,
"noUncheckedIndexedAccess": true
"noUncheckedIndexedAccess": true,
"verbatimModuleSyntax": true
},
}

0 comments on commit 015142f

Please sign in to comment.