Skip to content

Commit a3b7ba2

Browse files
author
Loëck Vézien
committed
yarn.lock
1 parent d56b47f commit a3b7ba2

File tree

56 files changed

+1194
-1104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1194
-1104
lines changed

.eslintrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
2-
"extends": "airbnb-base",
2+
"extends": [
3+
"airbnb-base",
4+
"prettier"
5+
],
36
"parser": "babel-eslint",
47
"rules": {
58
"comma-dangle": [ 2, "always-multiline" ],

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package.json

.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 80,
3+
"semi": false,
4+
"singleQuote": true,
5+
"trailingComma": "all"
6+
}

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"name": "mjml-master",
33
"private": true,
44
"scripts": {
5-
"build": "lerna run build --parallel",
65
"build:watch": "lerna run build --parallel -- -- -w",
6+
"build": "lerna run build --parallel",
77
"lint": "eslint .",
8-
"postinstall": "lerna bootstrap"
8+
"postinstall": "lerna bootstrap",
9+
"prettier": "prettier --write \"packages/**/{src,bin}/**/*.?(js|json)\""
910
},
1011
"devDependencies": {
1112
"babel-cli": "^6.26.0",
@@ -19,9 +20,11 @@
1920
"es6-promisify": "^5.0.0",
2021
"eslint": "^4.5.0",
2122
"eslint-config-airbnb-base": "^11.3.2",
23+
"eslint-config-prettier": "^2.6.0",
2224
"eslint-plugin-import": "^2.7.0",
2325
"lerna": "^2.0.0",
2426
"opn": "^5.1.0",
27+
"prettier": "^1.7.3",
2528
"rimraf": "^2.6.1"
2629
}
2730
}

packages/mjml-body/src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export default class MjBody extends BodyComponent {
2424
return `
2525
<div
2626
${this.htmlAttributes({
27-
class: this.getAttribute('css-class'),
28-
style: 'div',
29-
})}
27+
class: this.getAttribute('css-class'),
28+
style: 'div',
29+
})}
3030
>
3131
${this.renderChildren()}
3232
</div>

packages/mjml-button/src/index.js

+21-18
Original file line numberDiff line numberDiff line change
@@ -91,31 +91,34 @@ export default class MjButton extends BodyComponent {
9191
return `
9292
<table
9393
${this.htmlAttributes({
94-
align: this.getAttribute('align'),
95-
border: '0',
96-
cellpadding: '0',
97-
cellspacing: '0',
98-
role: 'presentation',
99-
style: 'table',
100-
})}
94+
align: this.getAttribute('align'),
95+
border: '0',
96+
cellpadding: '0',
97+
cellspacing: '0',
98+
role: 'presentation',
99+
style: 'table',
100+
})}
101101
>
102102
<tr>
103103
<td
104104
${this.htmlAttributes({
105-
align: 'center',
106-
bgcolor: this.getAttribute('background-color') === 'none' ? undefined : this.getAttribute('background-color'),
107-
role: 'presentation',
108-
style: 'td',
109-
valign: this.getAttribute('vertical-align'),
110-
})}
105+
align: 'center',
106+
bgcolor:
107+
this.getAttribute('background-color') === 'none'
108+
? undefined
109+
: this.getAttribute('background-color'),
110+
role: 'presentation',
111+
style: 'td',
112+
valign: this.getAttribute('vertical-align'),
113+
})}
111114
>
112115
<${tag}
113116
${this.htmlAttributes({
114-
href: this.getAttribute('href'),
115-
rel: this.getAttribute('rel'),
116-
style: 'content',
117-
target: tag === 'a' ? '_blank' : undefined,
118-
})}
117+
href: this.getAttribute('href'),
118+
rel: this.getAttribute('rel'),
119+
style: 'content',
120+
target: tag === 'a' ? '_blank' : undefined,
121+
})}
119122
>
120123
${this.getContent()}
121124
</${tag}>

packages/mjml-cli/src/client.js

+44-39
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,14 @@ const DEFAULT_OPTIONS = {
2020
let EXIT_CODE = 0
2121
let KEEP_OPEN = false
2222

23-
const error = (msg) => {
23+
const error = msg => {
2424
console.error(msg) // eslint-disable-line no-console
2525

2626
return process.exit(1)
2727
}
2828

29-
const pickArgs = args => (
30-
flow(
31-
pick(args),
32-
pickBy(e => negate(isNil)(e) && !(isArray(e) && isEmpty(e)))
33-
)
34-
)
29+
const pickArgs = args =>
30+
flow(pick(args), pickBy(e => negate(isNil)(e) && !(isArray(e) && isEmpty(e))))
3531

3632
const argv = yargs
3733
.options({
@@ -68,40 +64,43 @@ const argv = yargs
6864
},
6965
})
7066
.help()
71-
.version(`mjml-core: ${coreVersion}\nmjml-cli: ${cliVersion}`)
72-
.argv
73-
67+
.version(`mjml-core: ${coreVersion}\nmjml-cli: ${cliVersion}`).argv
7468

7569
const config = Object.assign(DEFAULT_OPTIONS, argv.c)
7670
const inputArgs = pickArgs(['r', 'w', 'i', '_'])(argv)
77-
const outputArgs = pickArgs(['o', 's'])(argv);
71+
const outputArgs = pickArgs(['o', 's'])(argv)
7872

7973
// implies (until yargs pr is accepted)
80-
[
74+
;[
8175
[Object.keys(inputArgs).length > 1, 'No input arguments received'],
8276
[Object.keys(inputArgs).length === 0, 'Too much input arguments received'],
8377
[Object.keys(outputArgs).length > 1, 'Too much output arguments received'],
84-
[argv.w && argv.w.length > 1 && !argv.o, 'Need an output option when watching files'],
85-
[argv.w
86-
&& argv.w.length > 1
87-
&& argv.o
88-
&& !isDirectory(argv.o)
89-
&& argv.o !== '',
90-
'Need an output option when watching files'],
91-
].forEach(v => (
92-
v[0] ? error(v[1]) : null
93-
))
78+
[
79+
argv.w && argv.w.length > 1 && !argv.o,
80+
'Need an output option when watching files',
81+
],
82+
[
83+
argv.w &&
84+
argv.w.length > 1 &&
85+
argv.o &&
86+
!isDirectory(argv.o) &&
87+
argv.o !== '',
88+
'Need an output option when watching files',
89+
],
90+
].forEach(v => (v[0] ? error(v[1]) : null))
9491

9592
const inputOpt = Object.keys(inputArgs)[0]
9693
const outputOpt = Object.keys(outputArgs)[0] || 's'
9794

98-
const inputFiles = isArray(inputArgs[inputOpt]) ? inputArgs[inputOpt] : [inputArgs[inputOpt]]
95+
const inputFiles = isArray(inputArgs[inputOpt])
96+
? inputArgs[inputOpt]
97+
: [inputArgs[inputOpt]]
9998
const inputs = []
10099

101100
switch (inputOpt) {
102101
case 'r':
103102
case '_': {
104-
flatMapPaths(inputFiles).forEach((file) => {
103+
flatMapPaths(inputFiles).forEach(file => {
105104
inputs.push(readFile(file))
106105
})
107106
break
@@ -120,14 +119,13 @@ switch (inputOpt) {
120119
const convertedStream = []
121120
const failedStream = []
122121

123-
inputs.forEach((i) => { // eslint-disable-line array-callback-return
122+
inputs.forEach(i => {
123+
// eslint-disable-line array-callback-return
124124
try {
125125
convertedStream.push(
126-
Object.assign(
127-
{},
128-
i,
129-
{ compiled: mjml2html(i.mjml, { ...config, filePath: i.file }) }
130-
)
126+
Object.assign({}, i, {
127+
compiled: mjml2html(i.mjml, { ...config, filePath: i.file }),
128+
}),
131129
)
132130
} catch (e) {
133131
EXIT_CODE = 2
@@ -136,10 +134,13 @@ inputs.forEach((i) => { // eslint-disable-line array-callback-return
136134
}
137135
})
138136

139-
failedStream.forEach(({ error, file }) => { // eslint-disable-line array-callback-return
137+
failedStream.forEach(({ error, file }) => {
138+
// eslint-disable-line array-callback-return
140139
console.error(`${file ? `File: ${file}\n` : null}${error}`) // eslint-disable-line no-console
141140

142-
if (config.stack) { console.error(error.stack) } // eslint-disable-line no-console
141+
if (config.stack) {
142+
console.error(error.stack)
143+
} // eslint-disable-line no-console
143144
})
144145

145146
if (!KEEP_OPEN && convertedStream.length === 0) {
@@ -149,21 +150,25 @@ if (!KEEP_OPEN && convertedStream.length === 0) {
149150
switch (outputOpt) {
150151
case 'o':
151152
if (inputs.length > 1 && (!isDirectory(argv.o) && argv.o !== '')) {
152-
error(`Multiple input files, but output option should be either a directory or an empty string: ${argv.o} given`)
153+
error(
154+
`Multiple input files, but output option should be either a directory or an empty string: ${argv.o} given`,
155+
)
153156
}
154157

155-
Promise
156-
.all(convertedStream.map(outputToFile(argv.o)))
158+
Promise.all(convertedStream.map(outputToFile(argv.o)))
157159
.then(() => {
158-
if (!KEEP_OPEN) { process.exit(EXIT_CODE) }
160+
if (!KEEP_OPEN) {
161+
process.exit(EXIT_CODE)
162+
}
159163
})
160164
.catch(() => {
161-
if (!KEEP_OPEN) { process.exit(1) }
165+
if (!KEEP_OPEN) {
166+
process.exit(1)
167+
}
162168
})
163169
break
164170
case 's':
165-
Promise
166-
.all(convertedStream.map(outputToConsole))
171+
Promise.all(convertedStream.map(outputToConsole))
167172
.then(() => process.exit(EXIT_CODE))
168173
.catch(() => process.exit(1))
169174
break
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
export default ({ compiled: { html }, file }) => (
2-
new Promise((resolve) => {
1+
export default ({ compiled: { html }, file }) =>
2+
new Promise(resolve => {
33
// eslint-disable-next-line
44
console.log(`<!-- FILE: ${file} -->\n${html}`)
55
resolve()
66
})
7-
)
+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs'
22
import path from 'path'
33

4-
export const isDirectory = (file) => {
4+
export const isDirectory = file => {
55
try {
66
const outputPath = path.resolve(process.cwd(), file)
77

@@ -11,17 +11,18 @@ export const isDirectory = (file) => {
1111
}
1212
}
1313

14-
const replaceExtension = input => input.replace(
15-
'.mjml',
16-
input.replace('.mjml', '').match(/(.)*\.(.)+$/g) ? '' : '.html'
17-
)
14+
const replaceExtension = input =>
15+
input.replace(
16+
'.mjml',
17+
input.replace('.mjml', '').match(/(.)*\.(.)+$/g) ? '' : '.html',
18+
)
1819

19-
const makeGuessOutputName = (outputPath) => {
20+
const makeGuessOutputName = outputPath => {
2021
if (isDirectory(outputPath)) {
2122
return input => path.join(outputPath, replaceExtension(input))
2223
}
2324

24-
return (input) => {
25+
return input => {
2526
if (!outputPath) {
2627
return replaceExtension(input)
2728
}
@@ -30,20 +31,19 @@ const makeGuessOutputName = (outputPath) => {
3031
}
3132
}
3233

33-
export default (outputPath) => {
34+
export default outputPath => {
3435
const guessOutputName = makeGuessOutputName(outputPath)
3536

36-
return ({ file, compiled: { html } }) => (
37+
return ({ file, compiled: { html } }) =>
3738
new Promise((resolve, reject) => {
3839
const outputName = guessOutputName(file)
3940

40-
fs.writeFile(outputName, html, (err) => {
41+
fs.writeFile(outputName, html, err => {
4142
if (err) {
4243
return reject(outputName)
4344
}
4445

4546
return resolve(outputName)
4647
})
4748
})
48-
)
4949
}

packages/mjml-cli/src/commands/readFile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import fs from 'fs'
22
import glob from 'glob'
33
import { flatMap } from 'lodash'
44

5-
export const flatMapPaths = paths => flatMap(paths, p => glob.sync(p, { nodir: true }))
5+
export const flatMapPaths = paths =>
6+
flatMap(paths, p => glob.sync(p, { nodir: true }))
67

7-
export default (path) => {
8+
export default path => {
89
try {
910
return { file: path, mjml: fs.readFileSync(path).toString() }
1011
} catch (e) {
@@ -13,4 +14,3 @@ export default (path) => {
1314
return {}
1415
}
1516
}
16-

0 commit comments

Comments
 (0)