optimize: `json.js` 从 `core` 转移到 `mitmproxy`

pull/300/head
王良 2024-04-18 12:08:53 +08:00
parent 7d45435883
commit fd8c6575b9
9 changed files with 15 additions and 8 deletions

View File

@ -2,7 +2,7 @@ const fs = require('fs')
const Shell = require('./shell')
const lodash = require('lodash')
const defConfig = require('./config/index.js')
const jsonApi = require('./json.js')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const request = require('request')
const path = require('path')
const log = require('./utils/util.log')

View File

@ -1,5 +1,5 @@
const nodeConfig = require('./config')
const jsonApi = require('../../../json.js')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const NodePlugin = function (context) {
const { config, shell, event, log } = context
const nodeApi = {

View File

@ -6,7 +6,7 @@ const fork = require('child_process').fork
const log = require('../../utils/util.log')
const fs = require('fs')
const path = require('path')
const jsonApi = require('../../json')
const jsonApi = require('@docmirror/mitmproxy/src/json')
let server = null
function fireStatus (status) {

View File

@ -2,7 +2,7 @@
* 获取环境变量
*/
const Shell = require('../shell')
const jsonApi = require('../../json')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const execute = Shell.execute
const executor = {
async windows (exec) {

View File

@ -1,4 +1,4 @@
const jsonApi = require('../src/json.js')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const DevSidecar = require('../index')
const fs = require('fs')
const log = require('../src/utils/util.log')

View File

@ -1,5 +1,5 @@
const server = require('@docmirror/mitmproxy')
const jsonApi = require('../src/json.js')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const path = require('path')
const home = process.env.USER_HOME || process.env.HOME || 'C:/Users/Administrator/'
const log = require('../src/utils/util.log')

View File

@ -6,7 +6,7 @@ import path from 'path'
const pk = require('../../../package.json')
const mitmproxyPath = path.join(__dirname, 'mitmproxy.js')
process.env.DS_EXTRA_PATH = path.join(__dirname, '../extra/')
const jsonApi = require('@docmirror/dev-sidecar/src/json.js')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const log = require('../../utils/util.log')
const getDefaultConfigBasePath = function () {

View File

@ -1,7 +1,7 @@
// eslint-disable-next-line no-unused-vars
const log = require('../utils/util.log')
const server = require('@docmirror/mitmproxy')
const jsonApi = require('@docmirror/dev-sidecar/src/json.js')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const configPath = process.argv[2]
const fs = require('fs')
const path = require('path')

View File

@ -9,5 +9,12 @@ module.exports = {
},
stringify (obj) {
return JSON.stringify(obj, null, '\t')
},
stringify2 (obj) {
try {
return JSON5.stringify(obj)
} catch (e) {
return obj.toString()
}
}
}