-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix, minor refactor, combine validate and generate, add support for @OData field in payload
- Loading branch information
Showing
5 changed files
with
262 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,5 @@ dist | |
.tern-port | ||
|
||
config.json | ||
output | ||
errors | ||
reso-schema-validation-temp | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const fs = require('fs'); | ||
const fsPromises = fs.promises; | ||
const path = require('path'); | ||
const { extractFilesFromZip } = require('../../common'); | ||
|
||
const processFiles = async ({ inputPath, outputPath }) => { | ||
try { | ||
const stats = await fsPromises.stat(inputPath); | ||
|
||
if (stats.isFile()) { | ||
await processFile({ filePath: inputPath, outputPath }); | ||
} else if (stats.isDirectory()) { | ||
const files = await fsPromises.readdir(inputPath); | ||
|
||
for (const file of files) { | ||
await processFile({ | ||
filePath: path.join(inputPath, file), | ||
outputPath | ||
}); | ||
} | ||
} else { | ||
console.error(`Unsupported file type: ${inputPath}`); | ||
} | ||
} catch (error) { | ||
console.log(error); | ||
return { error }; | ||
} | ||
}; | ||
|
||
const processFile = async ({ filePath, outputPath }) => { | ||
const ext = path.extname(filePath); | ||
|
||
if (ext === '.json') { | ||
await fsPromises.copyFile(filePath, path.join(outputPath, path.basename(filePath))); | ||
} else if (ext === '.zip') { | ||
await extractFilesFromZip({ | ||
zipPath: filePath, | ||
outputPath | ||
}); | ||
} else { | ||
console.error(`Unsupported file type: ${filePath}`); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
processFiles | ||
}; |
Oops, something went wrong.