Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
20岁爱吃必胜客
uni-app
提交
35963d01
U
uni-app
项目概览
20岁爱吃必胜客
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
35963d01
编写于
1月 06, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(cli): log
上级
704b6827
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
79 addition
and
12 deletion
+79
-12
packages/vue-cli-plugin-hbuilderx/__tests__/console.spec.js
packages/vue-cli-plugin-hbuilderx/__tests__/console.spec.js
+49
-0
packages/vue-cli-plugin-hbuilderx/__tests__/demo.js
packages/vue-cli-plugin-hbuilderx/__tests__/demo.js
+14
-0
packages/vue-cli-plugin-hbuilderx/packages/babel-plugin-console/dist/index.js
...gin-hbuilderx/packages/babel-plugin-console/dist/index.js
+8
-7
packages/vue-cli-plugin-uni/lib/format-log.js
packages/vue-cli-plugin-uni/lib/format-log.js
+8
-5
未找到文件。
packages/vue-cli-plugin-hbuilderx/__tests__/console.spec.js
0 → 100644
浏览文件 @
35963d01
const
path
=
require
(
'
path
'
)
const
{
transformSync
}
=
require
(
'
@babel/core
'
)
const
options
=
{
filename
:
'
/index.vue
'
,
configFile
:
false
,
minified
:
true
,
plugins
:
[
path
.
resolve
(
__dirname
,
'
../packages/babel-plugin-console/dist/index.js
'
)]
}
describe
(
'
console
'
,
()
=>
{
it
(
'
log
'
,
()
=>
{
expect
(
transformSync
(
`console.log('123')`
,
options
).
code
)
.
toBe
(
`__f__("log","123"," at /index.vue:1");`
)
expect
(
transformSync
(
`console.log('123',a,{a:1,b:2})`
,
options
).
code
)
.
toBe
(
`__f__("log","123",a,{a:1,b:2}," at /index.vue:1");`
)
})
it
(
'
debug
'
,
()
=>
{
expect
(
transformSync
(
`console.log('123')`
,
options
).
code
)
.
toBe
(
`__f__("log","123"," at /index.vue:1");`
)
expect
(
transformSync
(
`console.log('123',a,{a:1,b:2})`
,
options
).
code
)
.
toBe
(
`__f__("log","123",a,{a:1,b:2}," at /index.vue:1");`
)
})
it
(
'
info
'
,
()
=>
{
expect
(
transformSync
(
`console.info('123')`
,
options
).
code
)
.
toBe
(
`__f__("info","123"," at /index.vue:1");`
)
expect
(
transformSync
(
`console.info('123',a,{a:1,b:2})`
,
options
).
code
)
.
toBe
(
`__f__("info","123",a,{a:1,b:2}," at /index.vue:1");`
)
})
it
(
'
warn
'
,
()
=>
{
expect
(
transformSync
(
`console.warn('123')`
,
options
).
code
)
.
toBe
(
`__f__("warn","123"," at /index.vue:1");`
)
expect
(
transformSync
(
`console.warn('123',a,{a:1,b:2})`
,
options
).
code
)
.
toBe
(
`__f__("warn","123",a,{a:1,b:2}," at /index.vue:1");`
)
})
it
(
'
error
'
,
()
=>
{
expect
(
transformSync
(
`console.error('123')`
,
options
).
code
)
.
toBe
(
`__f__("error","123"," at /index.vue:1");`
)
expect
(
transformSync
(
`console.error('123',a,{a:1,b:2})`
,
options
).
code
)
.
toBe
(
`__f__("error","123",a,{a:1,b:2}," at /index.vue:1");`
)
})
})
packages/vue-cli-plugin-hbuilderx/__tests__/demo.js
0 → 100644
浏览文件 @
35963d01
const
path
=
require
(
'
path
'
)
const
{
transform
}
=
require
(
'
@babel/core
'
)
transform
(
`console.log('123')`
,
{
filename
:
'
/index.vue
'
,
configFile
:
false
,
minified
:
true
,
plugins
:
[
path
.
resolve
(
__dirname
,
'
../packages/babel-plugin-console/dist/index.js
'
)]
},
function
(
err
,
result
)
{
console
.
log
(
err
,
result
)
})
packages/vue-cli-plugin-hbuilderx/packages/babel-plugin-console/dist/index.js
浏览文件 @
35963d01
...
@@ -7,7 +7,6 @@ module.exports = function({
...
@@ -7,7 +7,6 @@ module.exports = function({
return
{
return
{
visitor
:
{
visitor
:
{
CallExpression
(
path
,
state
)
{
CallExpression
(
path
,
state
)
{
const
opts
=
state
.
opts
const
opts
=
state
.
opts
if
(
path
.
node
.
callee
.
object
&&
if
(
path
.
node
.
callee
.
object
&&
...
@@ -36,12 +35,14 @@ module.exports = function({
...
@@ -36,12 +35,14 @@ module.exports = function({
type
:
'
StringLiteral
'
,
type
:
'
StringLiteral
'
,
value
:
` at
${
file
}
:
${
path
.
node
.
loc
.
start
.
line
}
`
value
:
` at
${
file
}
:
${
path
.
node
.
loc
.
start
.
line
}
`
})
})
path
.
node
.
arguments
=
[
args
.
unshift
(
t
.
stringLiteral
(
path
.
node
.
callee
.
property
.
name
))
t
.
callExpression
(
path
.
replaceWith
(
t
.
callExpression
(
t
.
identifier
(
FORMAT_LOG
),
args
))
t
.
identifier
(
FORMAT_LOG
),
// path.node.arguments = [
args
// t.callExpression(
)
// t.identifier(FORMAT_LOG),
]
// args
// )
// ]
}
}
}
}
}
}
...
...
packages/vue-cli-plugin-uni/lib/format-log.js
浏览文件 @
35963d01
...
@@ -3,16 +3,19 @@ function typof (v) {
...
@@ -3,16 +3,19 @@ function typof (v) {
return
s
.
substring
(
8
,
s
.
length
-
1
)
return
s
.
substring
(
8
,
s
.
length
-
1
)
}
}
function
isDebugMode
()
{
function
isDebugMode
()
{
return
typeof
name
===
'
string
'
&&
name
===
'
uni-app
'
/* eslint-disable no-undef */
return
typeof
__channelId__
===
'
string
'
&&
__channelId__
}
}
export
default
function
formatLog
()
{
export
default
function
formatLog
()
{
for
(
var
_len
=
arguments
.
length
,
args
=
new
Array
(
_len
),
_key
=
0
;
_key
<
_len
;
_key
++
)
{
for
(
var
_len
=
arguments
.
length
,
args
=
new
Array
(
_len
),
_key
=
0
;
_key
<
_len
;
_key
++
)
{
args
[
_key
]
=
arguments
[
_key
]
args
[
_key
]
=
arguments
[
_key
]
}
}
if
(
isDebugMode
())
{
const
type
=
args
.
shift
()
return
args
if
(
isDebugMode
())
{
args
.
push
(
args
.
pop
().
replace
(
'
at
'
,
'
uni-app:///
'
))
return
console
[
type
][
'
apply
'
](
console
,
args
)
}
}
var
msgs
=
args
.
map
(
function
(
v
)
{
var
msgs
=
args
.
map
(
function
(
v
)
{
...
@@ -57,5 +60,5 @@ export default function formatLog () {
...
@@ -57,5 +60,5 @@ export default function formatLog () {
msg
=
msgs
[
0
]
msg
=
msgs
[
0
]
}
}
return
msg
console
[
type
](
msg
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录