Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. // Set of required script arguments
  2. const requiredArgs = ["user", "password"];
  3. // Parse the input arguments into an args object
  4. const args = {};
  5. for (let i = 0; i < process.argv.length; i++) {
  6. if (process.argv[i].startsWith("--")) {
  7. args[process.argv[i].replace("--", "")] = process.argv[i + 1];
  8. }
  9. }
  10. // Determine if any required arguments are missing
  11. const missingArgs = requiredArgs.filter((value) => !(value in args));
  12. // If there are missing arguments, report the missing args and exit.
  13. if (missingArgs.length > 0) {
  14. console.error(`Missing Script Arguments:`)
  15. console.error(missingArgs);
  16. console.error("");
  17. process.exit(1);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement