@reactful/create 0.0.85 → 0.0.86

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +33 -24
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -61,30 +61,39 @@ 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 response = await fetch(`${prefix}/contents/installation/${subdir}`)
65
- const contents = await response.json()
66
-
67
- if (!Array.isArray(contents) || !response.ok) {
68
- console.error('failed to download scafold from github...')
69
- console.log('textual: ', JSON.stringify(contents))
70
- console.log('array: ', Array.isArray(contents))
71
- console.log('code: ', response.status)
72
- console.log('url: ', response.url)
73
- }
74
-
75
- for (const item of contents) {
76
- if (item.type === 'dir' && item.name) {
77
- const from = `${subdir}/${item.name}`
78
- const goto = `${destination}/${item.name}`
79
- await downloadRepo(from, goto); continue
64
+ const address = `${prefix}/contents/installation/${subdir}`
65
+
66
+ try {
67
+ const response = await fetch(address)
68
+ const contents = await response.json()
69
+
70
+ if (!Array.isArray(contents) || !response.ok) {
71
+ console.log('url: ', response.url)
72
+ console.log('code: ', response.status)
73
+ console.log('array: ', Array.isArray(contents))
74
+ console.log('textual: ', JSON.stringify(contents))
75
+
76
+ throw 'failed to download scafold from github...'
80
77
  }
81
-
82
- if (item.type != 'file') continue
83
-
84
- const filename = path.join(destination, item.name)
85
- const response = await fetch(item.download_url)
86
- const filetext = await response.text()
87
-
88
- fs.writeFileSync(filename, filetext)
78
+
79
+ for (const item of contents) {
80
+ if (item.type === 'dir' && item.name) {
81
+ const from = `${subdir}/${item.name}`
82
+ const goto = `${destination}/${item.name}`
83
+ await downloadRepo(from, goto); continue
84
+ }
85
+
86
+ if (item.type != 'file') continue
87
+
88
+ const filename = path.join(destination, item.name)
89
+ const response = await fetch(item.download_url)
90
+ const filetext = await response.text()
91
+
92
+ fs.writeFileSync(filename, filetext)
93
+ }
94
+ }
95
+ catch(ex) {
96
+ console.log('url: ', address)
97
+ throw ex
89
98
  }
90
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactful/create",
3
- "version": "0.0.85",
3
+ "version": "0.0.86",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "description": "reactful scafold tool",