Last active
August 14, 2018 02:23
-
-
Save jbeard4/7f115ad7be8b99737da83c9fcb7eb3da to your computer and use it in GitHub Desktop.
Node script to read a CSV, and shell out to the ghi utility to create github issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const { exec } = require('child_process'); | |
const eachSeries = require('async/eachSeries'); | |
const x = fs.readFileSync('issues.tsv','utf8') | |
const arrs = x.split('\r\n').map(row => {const arr = row.split('\t'); const o = {priority: arr[0], date_reported: arr[1], reporter: arr[2], status: arr[3], description: arr[4], steps_to_reproduce: arr[5], screenshot: arr[6], dev_assigned: arr[7], dev_notes: arr[8], status: arr[9]}; return o}) | |
let i = 0; | |
eachSeries(arrs, (o, cb) => { | |
const cmd = `ghi open ${o.priority ? `-L ${o.priority}` : ''} -m $'${o.description.replace(/'/g,"\\'")}\\n\\n${o.date_reported ? `Date Reported: ${o.date_reported}\\n\\n` : ''}${o.reporter ? `Reporter: ${o.reporter}\\n\\n` : ''}${o.status ? `Status: ${o.status}\\n\\n` : ''}${o.steps_to_reproduce ? `Steps to reproduce: ${o.steps_to_reproduce.replace(/'/g,"\\'")}\\n\\n` : ''}${o.screenshot ? `Screenshot: ${o.screenshot}\\n\\n` : ''}${o.dev_assigned ? `Dev assigned: ${o.dev_assigned}\\n\\n` : ''}${o.dev_notes ? `Dev notes: ${o.dev_notes.replace(/'/g,"\\'")}` : ''}' -- streetlives/streetlives-web` | |
console.log(`cmd ${i++}:`, cmd); | |
exec(cmd, (error, stdout, stderr) => { | |
if (error) { | |
console.error(`exec error: ${error}`); | |
cb(error); | |
return; | |
} | |
console.log(`stdout: ${stdout}`); | |
console.log(`stderr: ${stderr}`); | |
cb(); | |
}); | |
}, () => { | |
console.log('done!') | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment