Skip to content

Commit 53604bb

Browse files
committed
fix: removed handeling of resolving static configPath CoCreate.config.js
1 parent daa6c50 commit 53604bb

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/server.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,7 @@ const mimeTypes = {
7777
".7z": "application/x-7z-compressed"
7878
}
7979

80-
module.exports = async function file(CoCreateConfig) {
81-
82-
let configFile = path.resolve(process.cwd(), 'CoCreate.config.js');
83-
if (fs.existsSync(configFile)) {
84-
CoCreateConfig = require(configFile);
85-
} else {
86-
console.log('CoCreate.config.js could not be found.')
87-
process.exit()
88-
}
89-
80+
module.exports = async function file(CoCreateConfig, configPath) {
9081
let { directories, sources } = CoCreateConfig;
9182
let config = await Config({
9283
organization_id: {
@@ -113,7 +104,7 @@ module.exports = async function file(CoCreateConfig) {
113104
}
114105
}
115106
}
116-
})
107+
}, null, null, configPath)
117108

118109
if (!config.organization_id || !config.host || !config.key && (!config.password || config.email)) {
119110
console.log('One or more required config params could not be found')
@@ -170,7 +161,15 @@ module.exports = async function file(CoCreateConfig) {
170161
let files = fs.readdirSync(entry);
171162

172163
for (let file of files) {
173-
if (exclude && exclude.includes(file)) continue
164+
let skip = false
165+
for (let i = 0; i < exclude.length; i++) {
166+
if (file.includes(exclude)) {
167+
skip = true
168+
break;
169+
}
170+
}
171+
if (skip) continue
172+
174173

175174
let isDirectory = fs.existsSync(`${entry}/${file}`) && fs.lstatSync(`${entry}/${file}`).isDirectory();
176175
let name = file
@@ -199,8 +198,6 @@ module.exports = async function file(CoCreateConfig) {
199198
else
200199
pathName = '/' + name
201200

202-
if (exclude && exclude.includes(pathName)) continue
203-
204201
if (isDirectory)
205202
mimeType = "text/directory"
206203
else
@@ -377,6 +374,8 @@ module.exports = async function file(CoCreateConfig) {
377374

378375
async function runStore(data) {
379376
try {
377+
if (data.object.name === 'prism-chunk.js')
378+
console.log('prism-chunk.js')
380379
let response;
381380
if (!data.object._id && !data.filter) {
382381
response = await crud.send({
@@ -424,9 +423,8 @@ module.exports = async function file(CoCreateConfig) {
424423

425424
delete newConfig.url
426425
delete newConfig.broadcast
427-
const write_str = `module.exports = ${JSON.stringify(newConfig, null, 4)};`;
428426

429-
fs.writeFileSync(configFile, write_str);
427+
fs.writeFileSync(configPath, `module.exports = ${JSON.stringify(newConfig, null, 4)};`);
430428
}
431429

432430
console.log('upload complete!');

0 commit comments

Comments
 (0)