FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
frontend/tools/messages.js at 143-sonobi-render · devhttps/frontend · GitHub
devhttps
/
frontend
Public
forked from
guardian/frontend
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
frontend
/
tools
/
messages.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
132 lines (119 loc) · 4.19 KB
Breadcrumbs
frontend
/
tools
/
messages.js
Copy path
File metadata and controls
132 lines (119 loc) · 4.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const
fs
=
require
(
'fs'
)
;
const
takeWhile
=
require
(
'lodash.takewhile'
)
;
const
notify
=
(
message
,
userOptions
=
{
}
,
type
=
'log'
)
=>
{
// Set the default text colour for info to black as white was hard to see
const
options
=
type
===
'info'
?
Object
.
assign
(
{
colour
:
'black'
,
codeColour
:
'white'
,
}
,
userOptions
)
:
userOptions
;
try
{
// eslint-disable-next-line global-require
require
(
'megalog'
)
[
type
]
(
message
,
options
)
;
}
catch
(
e
)
{
console
.
log
(
`
${
(
options
.
heading
?
`\n
${
options
.
heading
}
:\n\n`
:
''
)
+
message
}
\n\n(hint: you probably want to run \`make install\`)\n`
)
;
}
}
;
switch
(
process
.
argv
[
2
]
)
{
case
'describeMakefile'
:
{
const
messageLines
=
[
]
;
const
gutterWidth
=
27
;
// this flag could be anything, but the `--` makes it look real
const
listAll
=
process
.
argv
[
3
]
===
'--all'
;
// for all the lines in the makefile, construct the message
fs
.
readFileSync
(
'makefile'
,
'utf8'
)
.
split
(
'\n'
)
.
forEach
(
(
line
,
lineNumber
,
makefile
)
=>
{
// if this line is a target...
if
(
line
.
match
(
/
^
[
^
.
\s
#
]
/
)
&&
(
listAll
||
!
line
.
match
(
/
#
P
R
I
V
A
T
E
$
/
)
)
)
{
// see if there are any comments immediately before it
const
comments
=
takeWhile
(
makefile
.
slice
(
0
,
lineNumber
)
.
reverse
(
)
,
testLine
=>
testLine
.
match
(
/
^
#
/
)
)
// format the comments for output to CLI
.
map
(
comment
=>
comment
.
replace
(
/
#
\s
+
/
,
''
)
)
// put them back into correct order
.
reverse
(
)
;
// format the target name for output to CLI
const
targetName
=
line
.
split
(
':'
)
[
0
]
;
if
(
comments
.
length
)
{
// add the target name with the first comment following it
messageLines
.
push
(
`\`
${
targetName
}
\`
${
new
Array
(
gutterWidth
-
targetName
.
length
)
.
join
(
'.'
)
}
${
comments
.
join
(
' '
)
}
`
)
;
}
else
{
// just add the target name
messageLines
.
push
(
`\`
${
targetName
}
\``
)
;
}
}
// if we've got a divider, just add space to create a line break
if
(
line
.
match
(
/
^
#
\*
{
3
,
}
/
)
)
{
if
(
listAll
)
{
messageLines
.
push
(
`\n
${
line
.
replace
(
/
#
|
\*
/
g
,
''
)
.
trim
(
)
}
`
)
;
}
else
{
messageLines
.
push
(
' '
)
;
}
}
}
)
;
if
(
!
listAll
)
{
messageLines
.
push
(
'\nTo see the full set, run `make list`.'
)
;
}
notify
(
messageLines
.
join
(
'\n'
)
.
trim
(
)
,
{
heading
:
`
${
listAll
?
'All'
:
'Common'
}
Frontend make tasks`
,
}
,
'info'
)
;
break
;
}
case
'should-yarn'
:
{
notify
(
'Run `make install` and include any changes to `/yarn.lock` in your commit.'
,
{
heading
:
'Dependencies have changed'
,
}
,
'error'
)
;
break
;
}
case
'pasteup'
:
{
notify
(
'You will need to release a new version of pasteup to NPM once you’ve merged this branch to master.\n\nTo begin a new release, run `make pasteup`.'
,
{
heading
:
'Pasteup files have changed'
,
}
,
'info'
)
;
break
;
}
case
'install-steps'
:
{
notify
(
'Please run the following to complete your installation:'
,
{
heading
:
'Additional steps'
,
}
,
'info'
)
;
break
;
}
default
:
{
// do nothing
}
}
Back
|
FazBrowse Home
|
New Git URL