Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. const spawn = require('cross-spawn');
  2. const readline = require('readline').createInterface({
  3. input: process.stdin,
  4. output: process.stdout,
  5. });
  6.  
  7. const getNetsuiteDomain = require('./rest.js');
  8.  
  9. /**
  10. * @param {Config} config The configuration object
  11. * @return {Promise} Promise that will resolve after the SDF deployment is complete
  12. */
  13. module.exports = async function doSDFUpload(config) {
  14. let url = await getNetsuiteDomain(config, 'systemDomain');
  15.  
  16. return new Promise((resolve, reject) => {
  17. let sdfcli = spawn(
  18. 'sdfcli',
  19. [
  20. 'deploy',
  21. '-url',
  22. url,
  23. '-account',
  24. config.account,
  25. '-email',
  26. config.email,
  27. '-role',
  28. config.role,
  29. '-project',
  30. config.file,
  31. '-np',
  32. ],
  33. { stdio: ['pipe'] }
  34. )
  35. .on('error', reject)
  36. .on('close', () => {
  37. readline.close();
  38. resolve();
  39. });
  40.  
  41. sdfcli.stdout.on('data', data => {
  42. process.stdout.write(data);
  43.  
  44. let output = data.toString();
  45.  
  46. if (output.includes('Enter password')) {
  47. console.log('******');
  48. sdfcli.stdin.write(config.password + '\n');
  49. }
  50.  
  51. if (output.includes('Type YES to proceed with deploy')) {
  52. readline.question('', answer => sdfcli.stdin.write(answer + '\n'));
  53. }
  54.  
  55. if (output.includes('You are deploying to a Production account')) {
  56. readline.question('', answer => sdfcli.stdin.write(answer + '\n'));
  57. }
  58. });
  59. });
  60. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement