@reactful/create 0.0.85 → 0.0.87
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +29 -9
- package/package.json +1 -1
package/index.js
CHANGED
@@ -61,15 +61,14 @@ const downloadRepo = async (subfolder, destination) =>
|
|
61
61
|
|
62
62
|
async function downloadGitHub(user, repository, subdir, destination) {
|
63
63
|
const prefix = `https://api.github.com/repos/${user}/${repository}`
|
64
|
-
const
|
64
|
+
const address = `${prefix}/contents/installation/${subdir}`
|
65
|
+
const response = await fetch(address)
|
65
66
|
const contents = await response.json()
|
66
67
|
|
67
68
|
if (!Array.isArray(contents) || !response.ok) {
|
68
|
-
console.
|
69
|
-
|
70
|
-
|
71
|
-
console.log('code: ', response.status)
|
72
|
-
console.log('url: ', response.url)
|
69
|
+
console.log('moment: DIRECTORY...')
|
70
|
+
logging(response, contents)
|
71
|
+
throw 'failed to download scafold from github...'
|
73
72
|
}
|
74
73
|
|
75
74
|
for (const item of contents) {
|
@@ -81,10 +80,31 @@ async function downloadGitHub(user, repository, subdir, destination) {
|
|
81
80
|
|
82
81
|
if (item.type != 'file') continue
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
try {
|
84
|
+
const filename = path.join(destination, item.name)
|
85
|
+
const response = await fetch(item.download_url)
|
86
|
+
const filetext = await response.text()
|
87
|
+
}
|
88
|
+
catch(ex) {
|
89
|
+
console.log('MOMMENT: file...')
|
90
|
+
logging(response, contents)
|
91
|
+
throw ex
|
92
|
+
}
|
87
93
|
|
88
94
|
fs.writeFileSync(filename, filetext)
|
95
|
+
}
|
96
|
+
|
97
|
+
try {
|
89
98
|
}
|
99
|
+
catch(ex) {
|
100
|
+
console.log('fetching: ', address)
|
101
|
+
throw ex
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
function logging(response, contents) {
|
106
|
+
console.log('url: ', response.url)
|
107
|
+
console.log('code: ', response.status)
|
108
|
+
console.log('array: ', Array.isArray(contents))
|
109
|
+
console.log('textual: ', JSON.stringify(contents))
|
90
110
|
}
|