bin/gen-edgerc.js
function getClientAuth(callback) {
  console.log("This script will create a section named '" + args.section + "'" +
    "in the local file " + args.path + ".\n");

  // Read the client authorization file. If not found, notify user.
  if (args.file) {
    clientAuthData = fs.readFileSync(args.file, 'utf8');
    console.log("+++ Found authorization file: " + args.file);
    callback(clientAuthData);
  } else {
    // Present user with input dialogue requesting copy and paste of
    // client auth data.
    var input = [];

    var rl = readline.createInterface({
      input: process.stdin,
      output: process.stdout
    });

    var msg = "After authorizing your client in the OPEN API Administration " +
      "tool, \nexport the credentials and paste the contents of the export file " +
      "below (making sure to include the final blank line). \nThen enter " +
      "control-D to continue: \n\n>>>\n";

    rl.setPrompt(msg);
    rl.prompt();

    rl.on('line', function(cmd) {
      input.push(cmd);
    });

    rl.on('close', function(cmd) {
      if (input.length < 1) {
        // Data was not input, assumed early exit from the program.
        console.log("Kill command received without input. Exiting program.");
        process.exit(0);
      }
      console.log("\n<<<\n\n");
      clientAuthData = input.join('\n');
      callback(clientAuthData);
    });
  }
}
function getClientAuth(callback) {
  console.log("This script will create a section named '" + args.section + "'" +
    "in the local file " + args.path + ".\n");

  // Read the client authorization file. If not found, notify user.
  if (args.file) {
    clientAuthData = fs.readFileSync(args.file, 'utf8');
    console.log("+++ Found authorization file: " + args.file);
    callback(clientAuthData);
  } else {
    // Present user with input dialogue requesting copy and paste of
    // client auth data.
    var input = [];

    var rl = readline.createInterface({
      input: process.stdin,
      output: process.stdout
    });

    var msg = "After authorizing your client in the OPEN API Administration " +
      "tool, \nexport the credentials and paste the contents of the export file " +
      "below (making sure to include the final blank line). \nThen enter " +
      "control-D to continue: \n\n>>>\n";

    rl.setPrompt(msg);
    rl.prompt();

    rl.on('line', function(cmd) {
      input.push(cmd);
    });

    rl.on('close', function(cmd) {
      if (input.length < 1) {
        // Data was not input, assumed early exit from the program.
        console.log("Kill command received without input. Exiting program.");
        process.exit(0);
      }
      console.log("\n<<<\n\n");
      clientAuthData = input.join('\n');
      callback(clientAuthData);
    });
  }
}
function getClientAuth ( callback ) { console . log ( "This script will create a section named '" + args . section + "'" + "in the local file " + args . path + ".\n" ) ; // Read the client authorization file. If not found, notify user. if ( args . file ) { clientAuthData = fs . readFileSync ( args . file , 'utf8' ) ; console . log ( "+++ Found authorization file: " + args . file ) ; callback ( clientAuthData ) ; } else { // Present user with input dialogue requesting copy and paste of // client auth data. var input = [ ] ; var rl = readline . createInterface ( { input : process . stdin , output : process . stdout } ) ; var msg = "After authorizing your client in the OPEN API Administration " + "tool, \nexport the credentials and paste the contents of the export file " + "below (making sure to include the final blank line). \nThen enter " + "control-D to continue: \n\n>>>\n" ; rl . setPrompt ( msg ) ; rl . prompt ( ) ; rl . on ( 'line' , function ( cmd ) { input . push ( cmd ) ; } ) ; rl . on ( 'close' , function ( cmd ) { if ( input . length < 1 ) { // Data was not input, assumed early exit from the program. console . log ( "Kill command received without input. Exiting program." ) ; process . exit ( 0 ) ; } console . log ( "\n<<<\n\n" ) ; clientAuthData = input . join ( '\n' ) ; callback ( clientAuthData ) ; } ) ; } }
Gets the client authorization data by either reading the file path
passed in by the user or requesting the user to copy and paste the
data directly into the command line.

@param  {Function} callback Callback function accepting a data param
which will be called once the data is ready.
Gets the client authorization data by either reading the file path passed in by the user or requesting the user to copy and paste the data directly into the command line .