代码拉取完成,页面将自动刷新
#!/usr/bin/env node
// move the src files to mjs folder
// then copy over all files content and rename the extension to .ts
const args = process.argv.slice(2)
const { join } = require('path')
const { exec } = require('child_process')
const fs = require('fs-extra')
const glob = require('glob')
const rename = testStr => [testStr.substring(0, testStr.indexOf('.')), 'ts'].join('.')
console.log('in directory without the src!', args[0])
const baseDir = join(__dirname, args[0])
const srcDir = join(baseDir, 'src')
glob(join(srcDir , '**', '*.{mjs, js}'), function(err, files) {
if (err) {
console.error('Ooops', err)
return
}
// create a new filesArray with just the files / sub directory within the src
const filesArray = files.map(file => file.replace(srcDir + '/', ''))
// move everything into the a tmp directory
exec(`mv ${srcDir} ${join(baseDir, 'tmp')}`, (errors) => {
if (errors) {
console.error("Move folder failed!", errors)
return
}
Promise.all(
filesArray.map(filePath => (
fs.copy(
join(baseDir, 'tmp', filePath),
join(srcDir, rename(filePath))
)
))
)
.then(results => {
console.log(`Done!`)
})
})
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。