-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TeamDrive functionality #67
base: master
Are you sure you want to change the base?
Changes from all commits
183d455
1c33a73
5d9a3f0
e3875cd
f850705
2c02460
35e38cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ var defaults = require('../defaults'); | |
var manifestor = require('../manifestor'); | ||
var authenticate = require('../authenticate'); | ||
|
||
module.exports = function upload() { | ||
module.exports = function upload(options) { | ||
// console.log(options) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clean this ? :) |
||
console.log('Pushing back up to Google Drive...'); | ||
|
||
var fileId; // Hold in closure to avoid promise nesting | ||
|
@@ -21,7 +22,7 @@ module.exports = function upload() { | |
return manifestor.build(externalFiles); | ||
}) | ||
.then(function(files) { | ||
return sendToGoogle(files, fileId); | ||
return sendToGoogle(files, fileId, options.teamdrive); | ||
}) | ||
.then(function() { | ||
console.log('The latest files were successfully uploaded to your Apps Script project.'.green); | ||
|
@@ -31,15 +32,14 @@ module.exports = function upload() { | |
}); | ||
}; | ||
|
||
function sendToGoogle(files, id) { | ||
function sendToGoogle(files, id, supportsTeamDrives) { | ||
if (!files.length) { | ||
console.log('No Files to upload.'.red); | ||
throw 'manifest file length is 0'; | ||
} | ||
|
||
return authenticate() | ||
.then(function(auth) { | ||
var drive = google.drive({ version: 'v2', auth: auth }); | ||
var options = { | ||
fileId: id, | ||
media: { | ||
|
@@ -48,6 +48,12 @@ function sendToGoogle(files, id) { | |
} | ||
}; | ||
|
||
if (supportsTeamDrives) { | ||
console.log('teamdrive=true') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about editing the message that shows up when uploading (something like "Pushing back up to Google Drive (target project is inside a Team Drive)..."? |
||
options.supportsTeamDrives = true; | ||
} | ||
|
||
var drive = google.drive({ version: 'v2', auth: auth }); | ||
return Promise.promisify(drive.files.update)(options) | ||
.catch(function(err) { | ||
console.log('An error occured while running upload command: '.red + err.message); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't say better than @lricoy comment about updating the README