Created
December 18, 2019 16:50
-
-
Save ulisesantana/b16a32b9bbc86e00a88490ac91c964b1 to your computer and use it in GitHub Desktop.
Mock generator
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
const { address, company, random } = require('faker'); | |
const fs = require('fs'); | |
const path = require('path'); | |
fs.writeFile( | |
path.resolve('companies.mock.json'), | |
JSON.stringify( | |
[...new Array(60)].map(() => ({ | |
id: random.number(), | |
name: company.companyName(), | |
country: address.country(), | |
active: random.boolean(), | |
})), | |
null, | |
2 | |
), | |
{ encoding: 'utf8' }, | |
err => { | |
if (err) { | |
console.error(err.toString()); | |
throw err; | |
} | |
console.log('Mock created.'); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment