mirror of
https://gitee.com/dcloud/uni-preset-vue
synced 2025-04-28 16:00:12 +08:00
format manifest.json,pages.json
This commit is contained in:
parent
60776dcae6
commit
ef42aa530e
@ -2,6 +2,7 @@ const fs = require('fs')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const isBinary = require('isbinaryfile')
|
const isBinary = require('isbinaryfile')
|
||||||
|
const stripJsonComments = require('strip-json-comments')
|
||||||
|
|
||||||
|
|
||||||
async function generate(dir, files, base = '') {
|
async function generate(dir, files, base = '') {
|
||||||
@ -16,7 +17,12 @@ async function generate(dir, files, base = '') {
|
|||||||
if (isBinary.sync(sourcePath)) {
|
if (isBinary.sync(sourcePath)) {
|
||||||
files[path.join(base, rawPath)] = fs.readFileSync(sourcePath) // return buffer
|
files[path.join(base, rawPath)] = fs.readFileSync(sourcePath) // return buffer
|
||||||
} else {
|
} else {
|
||||||
files[path.join(base, rawPath)] = fs.readFileSync(sourcePath, 'utf-8')
|
const content = fs.readFileSync(sourcePath, 'utf-8')
|
||||||
|
if (sourcePath.indexOf('manifest.json') !== -1 || sourcePath.indexOf('pages.json') !== -1) {
|
||||||
|
files[path.join(base, rawPath)] = JSON.stringify(JSON.parse(stripJsonComments(content)), null, 2)
|
||||||
|
} else {
|
||||||
|
files[path.join(base, rawPath)] = content
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user