Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Set of required script arguments
- const requiredArgs = ["user", "password"];
- // Parse the input arguments into an args object
- const args = {};
- for (let i = 0; i < process.argv.length; i++) {
- if (process.argv[i].startsWith("--")) {
- args[process.argv[i].replace("--", "")] = process.argv[i + 1];
- }
- }
- // Determine if any required arguments are missing
- const missingArgs = requiredArgs.filter((value) => !(value in args));
- // If there are missing arguments, report the missing args and exit.
- if (missingArgs.length > 0) {
- console.error(`Missing Script Arguments:`)
- console.error(missingArgs);
- console.error("");
- process.exit(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement