-
Notifications
You must be signed in to change notification settings - Fork 23
/
main.js
41 lines (34 loc) · 1.17 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const path = require('path')
const fs = require('fs')
const rd = require('rd')
const exec = require('child_process').exec
const { genImages } = require('./lib/makeImgs')
const { genVideo } = require('./lib/makeVideo')
const { createProjectDir, dateFormat } = require('./lib/utils')
const dir = '粉色桌面壁纸'
const title = dir
const desc = '粉色桌布,清新治愈 ~'
// -------------
const source = './files/'
const dist = './project/'
const fileList = []
rd.eachFileFilterSync(path.resolve(__dirname, `${source}${dir}/`), /\.(jpg|png|jpeg|bmp)$/, function (f, s) {
fileList.push(f)
})
function copyImg (dir) {
const copyToDir = '/source'
fs.mkdirSync(`${dir}${copyToDir}`)
fileList.forEach(from => {
const to = dir + copyToDir + '/' + path.basename(from)
fs.copyFileSync(from, `${to}`)
})
}
async function main (title, desc, list, date = dateFormat('mm-dd')) {
const dir = createProjectDir(path.resolve(__dirname, `${dist}${title}_${date}`))
const imgs = await genImages(title, desc, list, dir)
const video = await genVideo(imgs, dir)
console.log('log => : main -> video', video)
exec(`open ${dir}`)
copyImg(dir)
}
main(title, desc, fileList)