Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dcloudio/uni-cli-shared

Package Overview
Dependencies
Maintainers
3
Versions
1739
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dcloudio/uni-cli-shared - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

8

lib/index.js

@@ -38,3 +38,5 @@ const tags = require('./tags')

getPlatformCompiler,
getPlatformCssVars
getPlatformCssVars,
jsPreprocessOptions,
htmlPreprocessOptions
} = require('./platform')

@@ -66,3 +68,5 @@

parseManifestJson,
convertStaticStyle
convertStaticStyle,
jsPreprocessOptions,
htmlPreprocessOptions
}
const fs = require('fs')
const path = require('path')
const stripJsonComments = require('strip-json-comments')
const preprocessor = require('@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/preprocess')
const {
jsPreprocessOptions
} = require('./platform')
function parseJson (content) {
content = typeof content === 'string' ? JSON.parse(stripJsonComments(content)) : content
function parseJson (content, preprocess = false) {
if (typeof content === 'string') {
if (preprocess) {
content = preprocessor.preprocess(content, jsPreprocessOptions.context, {
type: jsPreprocessOptions.type
})
}
content = JSON.parse(stripJsonComments(content))
}
content = JSON.stringify(content)

@@ -15,3 +27,3 @@ .replace(/\u2028/g, '\\u2028')

function getJson (jsonFileName) {
function getJson (jsonFileName, preprocess = false) {
const jsonFilePath = path.resolve(process.env.UNI_INPUT_DIR, jsonFileName)

@@ -22,3 +34,3 @@ if (!fs.existsSync(jsonFilePath)) {

try {
return parseJson(fs.readFileSync(jsonFilePath, 'utf8'))
return parseJson(fs.readFileSync(jsonFilePath, 'utf8'), preprocess)
} catch (e) {

@@ -25,0 +37,0 @@ throw new Error(jsonFileName + ' 解析失败')

@@ -14,7 +14,7 @@ const fs = require('fs')

function getPagesJson () {
return processPagesJson(getJson('pages.json'))
return processPagesJson(getJson('pages.json', true))
}
function parsePagesJson (content) {
return processPagesJson(parseJson(content))
return processPagesJson(parseJson(content, true))
}

@@ -21,0 +21,0 @@

@@ -66,5 +66,26 @@ const fs = require('fs')

const preprocessContext = {
[process.env.UNI_PLATFORM.toUpperCase()]: true
}
if (process.env.UNI_PLATFORM.indexOf('mp-') === 0) {
preprocessContext['MP'] = true
}
if (process.env.UNI_PLATFORM.indexOf('app-') === 0) {
preprocessContext['APP'] = true
}
const isInHBuilderX = fs.existsSync(path.resolve(__dirname, '../../vue-cli-plugin-hbuilderx'))
module.exports = {
isInHBuilderX,
jsPreprocessOptions: {
type: 'js',
context: preprocessContext
},
htmlPreprocessOptions: {
type: 'html',
context: preprocessContext
},
getPlatformExts () {

@@ -71,0 +92,0 @@ return EXTS[process.env.UNI_PLATFORM]

{
"name": "@dcloudio/uni-cli-shared",
"version": "0.1.1",
"version": "0.1.2",
"description": "uni-cli-shared",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc