mirror of
https://github.com/zhigang1992/react-native-chat-ui.git
synced 2026-05-14 23:33:39 +08:00
25 lines
567 B
JavaScript
Executable File
25 lines
567 B
JavaScript
Executable File
const casual = require('casual')
|
|
const fs = require('fs')
|
|
const { v4: uuidv4 } = require('uuid')
|
|
|
|
let numberOfMessages = 10
|
|
const arg = process.argv.slice(2)[0]
|
|
|
|
if (!isNaN(arg) && parseInt(arg) > 0) {
|
|
numberOfMessages = parseInt(arg)
|
|
}
|
|
|
|
const messages = [...Array(numberOfMessages)].map(() => {
|
|
const random = Math.round(Math.random())
|
|
const text = random ? casual.text : casual.sentence
|
|
const data = {
|
|
id: uuidv4(),
|
|
text,
|
|
}
|
|
return data
|
|
})
|
|
|
|
const json = `${JSON.stringify(messages, null, 2)}\n`
|
|
|
|
fs.writeFile('src/messages.json', json, () => {})
|