@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.
Files changed (2) hide show
  1. package/index.js +29 -9
  2. 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 response = await fetch(`${prefix}/contents/installation/${subdir}`)
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.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)
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
- const filename = path.join(destination, item.name)
85
- const response = await fetch(item.download_url)
86
- const filetext = await response.text()
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactful/create",
3
- "version": "0.0.85",
3
+ "version": "0.0.87",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "description": "reactful scafold tool",