update prepublish process

This commit is contained in:
jiaming743 2019-07-03 18:56:55 +08:00
parent bfc7cc7c57
commit 3fb3936aa9
3 changed files with 32 additions and 8 deletions

View File

@ -1,5 +1,6 @@
const { copyDir, fileForEach } = require('./plugin/fs')
const { print } = require('./plugin/print')
const { copyDir, fileForEach, readFile } = require('./plugin/fs')
const print = require('./plugin/print')
const path = require('path')
const PACKAGE_SRC = './src'
const COMPILE_SRC = './lib'
@ -13,8 +14,18 @@ async function start () {
return false
}
fileForEach(COMPILE_SRC, src => {
print.tip(src)
const abstract = await abstractLessFromVue()
}
async function abstractLessFromVue () {
fileForEach(COMPILE_SRC, async src => {
if (path.extname(src) !== '.vue') return
const data = await readFile(src).split('<style>')
const style = data
console.warn(data)
})
}

View File

@ -281,6 +281,20 @@ async function fileForEach (src, callback) {
return true
}
async function readFile (src, encoding = 'utf8') {
return new Promise(resolve => {
fs.readFile(src, encoding, (err, data) => {
if (err) {
console.warn(err)
resolve(false)
} else {
resolve(data)
}
})
})
}
module.exports = {
readDir,
stat,
@ -289,5 +303,6 @@ module.exports = {
emptyDir,
unlinkDirFileByExtname,
copyDir,
fileForEach
fileForEach,
readFile
}

View File

@ -16,6 +16,4 @@ const print = {
}
}
module.exports = {
print
}
module.exports = print