-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
175 additions
and
67 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
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,34 @@ | ||
[ | ||
{ | ||
"id": "106678", | ||
"title": "Jungle Erotic", | ||
"poster": "https://image.tmdb.org/t/p/w1280/rkMHlp42CDJUEB4GKsn3LC5znGC.jpg", | ||
"overview": "Young women have an adventure in the African jungle - where they are harassed by gentle men, and wild monkeys.", | ||
"release_date": 26265600, | ||
"genre": [ | ||
"Adventure", | ||
"Drama" | ||
] | ||
}, | ||
{ | ||
"id": "490410", | ||
"title": "48 Christmas Wishes", | ||
"poster": "https://image.tmdb.org/t/p/w1280/mrcA62O9j8y4gsSpftMKVcvrzCI.jpg", | ||
"overview": "Holiday magic has never gleamed brighter as Santa’s Elves head out on an adventure to bring every boy and girl their Christmas wish while also bringing a family back together in this heartfelt Christmas movie from Gaumont. After accidentally destroying a bag of Christmas wishes from a small town on the eve of Christmas Eve, two junior elves learn that if even one wish goes unfulfilled, Christmas could be extinguished forever. For the first time in their lives, the elves Mindy and Cam venture out of the North Pole and sneak into Minnedoza to collect the lost wishes. Along the way they enlist the help of young Blake, whose family has a difficult time celebrating Christmas since his father died. With their deadline fast approaching, Mindy and Cam have only one more wish to find…but whose could it be? It’s up to Mindy and Cam to find out and save Christmas!", | ||
"release_date": 1512086400, | ||
"genre": [ | ||
"Family", | ||
"Adventure", | ||
"Comedy", | ||
"TV Movie" | ||
] | ||
}, | ||
{ | ||
"id": "285841", | ||
"title": "Elephant Song", | ||
"poster": "https://image.tmdb.org/t/p/w1280/9pHl6RmMIDyPmQW1XUJ2Mahsr3M.jpg", | ||
"overview": "A psychiatrist is drawn into a complex mind game when he questions a disturbed patient about the disappearance of a colleague.", | ||
"release_date": 1409792400, | ||
"genre": [] | ||
} | ||
] |
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,24 @@ | ||
[ | ||
{ | ||
"id": "481370", | ||
"title": "Bigger", | ||
"poster": "https://image.tmdb.org/t/p/w1280/f6rmiFTfT3Rf9XDrXfLO6XcAgWn.jpg", | ||
"overview": "The inspirational tale of the grandfathers of the fitness movement as we now know it, Joe & Ben Weider. Battling anti-Semitism, racism and extreme poverty, the brothers beat all odds to build an empire & inspire future generations.", | ||
"release_date": 1539392400, | ||
"genre": [ | ||
"Drama" | ||
] | ||
}, | ||
{ | ||
"id": "31357", | ||
"title": "Waiting to Exhale", | ||
"poster": "https://image.tmdb.org/t/p/w1280/4wjGMwPsdlvi025ZqR4rXnFDvBz.jpg", | ||
"overview": "Cheated on, mistreated and stepped on, the women are holding their breath, waiting for the elusive 'good man' to break a string of less-than-stellar lovers. Friends and confidants Vannah, Bernie, Glo and Robin talk it all out, determined to find a better way to breathe.", | ||
"release_date": 819590400, | ||
"genre": [ | ||
"Comedy", | ||
"Drama", | ||
"Romance" | ||
] | ||
} | ||
] |
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,18 @@ | ||
#!/usr/bin/env node | ||
const combineJson = require('./combine-json'); | ||
|
||
(async () => { | ||
console.log(combineJson); | ||
try { | ||
if (process.argv.length === 2) { | ||
console.log(chalk.red('Error: Missing path argument')); | ||
} | ||
else { | ||
await combineJson(process.argv[2], process.argv[3]) | ||
} | ||
} | ||
catch(e) { | ||
console.error(e); | ||
throw(e) | ||
} | ||
})() |
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,56 @@ | ||
const path = require('path') | ||
const fs = require('fs') | ||
|
||
function resolveDir({ dir }) { | ||
dir = path.resolve(dir); | ||
if (!fs.existsSync(dir)) { // test for Fully Qualified path | ||
console.log(`Error: ${dir} no such named directory`); | ||
process.exit() | ||
} | ||
return dir; | ||
} | ||
|
||
function outputFile({ dirName, fileName = undefined }) { | ||
fileName = fileName || 'combined.json'; | ||
return `${dirName}/${fileName}`; | ||
} | ||
|
||
function inputFilesAndDir({ inputDir }) { | ||
const resolvedDir = resolveDir({ dir: inputDir}) | ||
const inputDirPath = resolvedDir + ((resolvedDir[resolvedDir.length - 1] === '/') ? '' : '/') // add slash at the end of the dir if it is not there yet | ||
const filesName = fs.readdirSync(inputDirPath) // read all files names in dir | ||
return { | ||
inputDirPath, | ||
filesName | ||
} | ||
} | ||
|
||
function resolveOutputFilePath({ fileName }) { | ||
const workingDir = process.cwd(); | ||
const outputFilePath = outputFile({ dirName: workingDir, fileName}); | ||
createFileIfNotExist(outputFilePath) | ||
return outputFilePath | ||
} | ||
|
||
|
||
function createFileIfNotExist({ file }) { | ||
if (fs.existsSync(file)) { | ||
fs.writeFileSync(file, ""); | ||
} | ||
} | ||
|
||
function filterNonJson({ filesName }){ | ||
return filesName.reduce((acc, file)=>{ | ||
if (path.extname(file)=== '.json') return [...acc, file]; | ||
return acc; | ||
}, []); | ||
} | ||
|
||
module.exports = { | ||
resolveDir, | ||
outputFile, | ||
inputFilesAndDir, | ||
resolveOutputFilePath, | ||
createFileIfNotExist, | ||
filterNonJson | ||
} |
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,4 @@ | ||
const combineJson = require('./combine-json') | ||
|
||
|
||
module.exports = combineJson |