sfc-utils 1.4.33 → 1.4.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/copy/docs.js +10 -8
- package/package.json +1 -1
package/copy/docs.js
CHANGED
|
@@ -19,24 +19,24 @@ var archieml = require("archieml");
|
|
|
19
19
|
var htmlparser = require("htmlparser2");
|
|
20
20
|
var Entities = require("html-entities").AllHtmlEntities;
|
|
21
21
|
|
|
22
|
-
let googleAuth = (config, directory = null, filenames = null) => {
|
|
22
|
+
let googleAuth = (config, directory = null, filenames = null, useID = null) => {
|
|
23
23
|
var auth = null;
|
|
24
24
|
authObj
|
|
25
25
|
.authenticate({ fallback: false })
|
|
26
26
|
.then((resp) => {
|
|
27
27
|
auth = resp;
|
|
28
|
-
grabDocs(auth, config, directory, filenames).catch(() => {
|
|
28
|
+
grabDocs(auth, config, directory, filenames, useID).catch(() => {
|
|
29
29
|
// If the first attempt failed, then make another req using the fallback
|
|
30
30
|
authObj.authenticate({ fallback: true }).then((resp) => {
|
|
31
31
|
auth = resp;
|
|
32
|
-
grabDocs(auth, config, directory, filenames);
|
|
32
|
+
grabDocs(auth, config, directory, filenames, useID);
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
})
|
|
36
36
|
.catch(() => {
|
|
37
37
|
// Failure if we fall back but there's no token
|
|
38
38
|
auth = authObj.task();
|
|
39
|
-
grabDocs(auth, config, directory, filenames);
|
|
39
|
+
grabDocs(auth, config, directory, filenames, useID);
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
42
|
|
|
@@ -51,7 +51,7 @@ var camelCase = function (str) {
|
|
|
51
51
|
* https://console.developers.google.com/apis/api/drive.googleapis.com/quotas?project=<project>
|
|
52
52
|
* where <project> is the project you authenticated with using `grunt google-auth`
|
|
53
53
|
*/
|
|
54
|
-
let grabDocs = (auth, config, directory = null, filenames = null) => {
|
|
54
|
+
let grabDocs = (auth, config, directory = null, filenames = null, useID = null) => {
|
|
55
55
|
return new Promise((resolve, reject) => {
|
|
56
56
|
var drive = google.drive({
|
|
57
57
|
auth,
|
|
@@ -75,9 +75,11 @@ let grabDocs = (auth, config, directory = null, filenames = null) => {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
var filename = meta.data.name.replace(/\s+/g, "_");
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
if (useID) {
|
|
79
|
+
// If we want to use the ID as the filename, do it
|
|
80
|
+
filename = fileId;
|
|
81
|
+
} else if (filenames) {
|
|
82
|
+
//find the appropriate filename if filenames arr is included in params
|
|
81
83
|
let match = filenames.find((f) => f.id === fileId);
|
|
82
84
|
filename = match.name;
|
|
83
85
|
}
|