| 32 | }; |
| 33 | |
| 34 | function sendToGoogle(files, id) { |
| 35 | if (!files.length) { |
| 36 | console.log('No Files to upload.'.red); |
| 37 | throw 'manifest file length is 0'; |
| 38 | } |
| 39 | |
| 40 | return authenticate() |
| 41 | .then(function(auth) { |
| 42 | var drive = google.drive({ version: 'v2', auth: auth }); |
| 43 | var options = { |
| 44 | fileId: id, |
| 45 | media: { |
| 46 | mimeType: 'application/vnd.google-apps.script+json', |
| 47 | body: JSON.stringify({ files: files }) |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | return Promise.promisify(drive.files.update)(options) |
| 52 | .catch(function(err) { |
| 53 | console.log('An error occured while running upload command: '.red + err.message); |
| 54 | throw err; |
| 55 | }); |
| 56 | }); |
| 57 | } |