live-dev-server
Advanced tools
Comparing version 0.9.1 to 0.9.2
const path = require('path') | ||
const fs = require('fs') | ||
const defaultWorkspace = `./src` | ||
const projectRoot = process.cwd() | ||
const { Log } = require('./log') | ||
const CUSTOME_INJECT_CODE_MARK = `//////` | ||
@@ -28,6 +28,6 @@ | ||
let options = Object.assign({}, defaultOptions) | ||
let customConfig = {} | ||
// 读取配置文件 | ||
try { | ||
customConfig = require(path.join(projectRoot, `./lds.config.js`)) | ||
let customConfig = readConfigFile() | ||
if (customConfig) { | ||
Object.assign(options, customConfig, { | ||
@@ -37,8 +37,5 @@ // 优先级lds配置里的root->配置里的workspace->默认的root | ||
}) | ||
} catch (error) { | ||
config = options | ||
Log.info('没有lds.config.js配置文件') | ||
} | ||
let { workspace, root, ...restConfig } = options | ||
let extra = { | ||
@@ -48,5 +45,24 @@ workspace: path.join(projectRoot, workspace), | ||
} | ||
// TODO deep merge? | ||
Object.assign(options, restConfig, extra) | ||
function readConfigFile() { | ||
let oldConfigPath = path.join(projectRoot, `./lds.config.js`) | ||
let configPath = path.join(projectRoot, `./live.config.js`) | ||
let isExists = isExsistsSync(configPath) | ||
if (!isExists) { | ||
configPath = oldConfigPath | ||
isExists = isExsistsSync(oldConfigPath) | ||
} | ||
if (isExists) return require(configPath) | ||
return null | ||
} | ||
function isExsistsSync(filePath) { | ||
return fs.existsSync(filePath) | ||
} | ||
module.exports = { | ||
@@ -53,0 +69,0 @@ options, |
{ | ||
"name": "live-dev-server", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"description": "develop env, watch files change", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
13770
346
3