@reactful/create 0.0.87 → 0.0.89

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 +11 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -81,17 +81,21 @@ async function downloadGitHub(user, repository, subdir, destination) {
81
81
  if (item.type != 'file') continue
82
82
 
83
83
  try {
84
- const filename = path.join(destination, item.name)
84
+ const filePath = path.join(destination, item.name)
85
85
  const response = await fetch(item.download_url)
86
- const filetext = await response.text()
86
+ const fileText = await response.text()
87
+ const baseFile = path.dirname(filePath)
88
+ const notFound = fs.existsSync(baseFile) == false
89
+
90
+ if (notFound) fs.mkdirSync(baseFile, { recursive: true })
91
+
92
+ fs.writeFileSync(filePath, fileText)
87
93
  }
88
94
  catch(ex) {
89
95
  console.log('MOMMENT: file...')
90
- logging(response, contents)
96
+ logging(response, contents, item.download_url)
91
97
  throw ex
92
98
  }
93
-
94
- fs.writeFileSync(filename, filetext)
95
99
  }
96
100
 
97
101
  try {
@@ -102,9 +106,10 @@ async function downloadGitHub(user, repository, subdir, destination) {
102
106
  }
103
107
  }
104
108
 
105
- function logging(response, contents) {
109
+ function logging(response, contents, download) {
106
110
  console.log('url: ', response.url)
107
111
  console.log('code: ', response.status)
108
112
  console.log('array: ', Array.isArray(contents))
109
113
  console.log('textual: ', JSON.stringify(contents))
114
+ console.log('download: ', item.download_url)
110
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactful/create",
3
- "version": "0.0.87",
3
+ "version": "0.0.89",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "description": "reactful scafold tool",