Skip to content

Commit fbfb9e8

Browse files
committed
run prettier on scripts/
1 parent 7c35dac commit fbfb9e8

File tree

5 files changed

+54
-22
lines changed

5 files changed

+54
-22
lines changed

scripts/bundle-data-dir.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ if (process.mainModule === module) {
2121
// exported module
2222
module.exports = bundleDataDir
2323
function bundleDataDir({fromDir, toFile}) {
24-
const files = fs.readdirSync(fromDir).filter(junk.not).map(f => path.join(fromDir, f))
24+
const files = fs
25+
.readdirSync(fromDir)
26+
.filter(junk.not)
27+
.map(f => path.join(fromDir, f))
2528
if (!files.length) {
2629
return
2730
}
@@ -37,6 +40,7 @@ function bundleDataDir({fromDir, toFile}) {
3740
const dated = {data: loaded}
3841
const output = JSON.stringify(dated, null, 2) + '\n'
3942

40-
const outStream = toFile === '-' ? process.stdout : fs.createWriteStream(toFile)
43+
const outStream =
44+
toFile === '-' ? process.stdout : fs.createWriteStream(toFile)
4145
outStream.write(output)
4246
}

scripts/bundle-data.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ const convertDataFile = require('./convert-data-file')
88

99
const isDir = pth => fs.statSync(pth).isDirectory()
1010
const isFile = pth => fs.statSync(pth).isFile()
11-
const readDir = pth => fs.readdirSync(pth).filter(junk.not).filter(entry => !entry.startsWith('_'))
12-
const findDirsIn = pth => readDir(pth).filter(entry => isDir(path.join(pth, entry)))
13-
const findFilesIn = pth => readDir(pth).filter(entry => isFile(path.join(pth, entry)))
11+
12+
const readDir = pth =>
13+
fs
14+
.readdirSync(pth)
15+
.filter(junk.not)
16+
.filter(entry => !entry.startsWith('_'))
17+
18+
const findDirsIn = pth =>
19+
readDir(pth).filter(entry => isDir(path.join(pth, entry)))
20+
21+
const findFilesIn = pth =>
22+
readDir(pth).filter(entry => isFile(path.join(pth, entry)))
1423

1524
const args = process.argv.slice(2)
1625
const fromDir = args[0]

scripts/convert-data-file.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (process.mainModule === module) {
1919

2020
// exported module
2121
module.exports = convertDataFile
22-
function convertDataFile({fromFile, toFile, toFileType="json"}) {
22+
function convertDataFile({fromFile, toFile, toFileType = 'json'}) {
2323
const contents = fs.readFileSync(fromFile, 'utf-8')
2424
let output = contents
2525

@@ -32,7 +32,7 @@ function convertDataFile({fromFile, toFile, toFileType="json"}) {
3232
output = processYaml(contents)
3333
break
3434
case 'css':
35-
if (toFileType === "css") {
35+
if (toFileType === 'css') {
3636
output = contents
3737
} else {
3838
output = processCSS(contents)
@@ -46,9 +46,8 @@ function convertDataFile({fromFile, toFile, toFileType="json"}) {
4646

4747
output = output + '\n'
4848

49-
const outStream = toFile === '-'
50-
? process.stdout
51-
: fs.createWriteStream(toFile)
49+
const outStream =
50+
toFile === '-' ? process.stdout : fs.createWriteStream(toFile)
5251
outStream.write(output)
5352
}
5453

scripts/make-icons.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ const spawn = (cmd, ...args) => {
66
childSpawn(cmd, args)
77
}
88

9-
const resize = (img, width, toFile) => spawn('convert', img, '-resize', `${width}x${width}`, toFile)
9+
const resize = (img, width, toFile) =>
10+
spawn('convert', img, '-resize', `${width}x${width}`, toFile)
1011

1112
// iOS app icons
1213
const iosSizes = [[29, 1], [29, 2], [29, 3], [40, 2], [40, 3], [60, 2], [60, 3]]
1314
for (const [width, density] of iosSizes) {
14-
resize(source, width * density, `icons/ios/AppIcon.appiconset/Icon-${width}@${density}x.png`)
15+
resize(
16+
source,
17+
width * density,
18+
`icons/ios/AppIcon.appiconset/Icon-${width}@${density}x.png`,
19+
)
1520
}
1621

1722
// iTunes icons

scripts/validate-data.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ const SCHEMA_BASE = path.join(__dirname, '..', 'data', '_schemas')
1111
const DATA_BASE = path.join(__dirname, '..', 'data')
1212

1313
const isDir = pth => tryBoolean(() => fs.statSync(pth).isDirectory())
14-
const readYaml = pth => JSON.parse(JSON.stringify(yaml.safeLoad(fs.readFileSync(pth, 'utf-8'), {filename: pth})))
15-
const readDir = pth => fs.readdirSync(pth).filter(junk.not).filter(entry => !entry.startsWith('_'))
14+
const readYaml = pth =>
15+
JSON.parse(
16+
JSON.stringify(
17+
yaml.safeLoad(fs.readFileSync(pth, 'utf-8'), {filename: pth}),
18+
),
19+
)
20+
21+
const readDir = pth =>
22+
fs
23+
.readdirSync(pth)
24+
.filter(junk.not)
25+
.filter(entry => !entry.startsWith('_'))
1626

1727
/// MARK: program
1828

@@ -78,20 +88,26 @@ function parseArgs(argv) {
7888
console.error()
7989
console.error('Arguments:')
8090
console.error(' <blank>: validates all schemas and data')
81-
console.error(' [schema-name]+: validates the schema and data for the given schema')
91+
console.error(
92+
' [schema-name]+: validates the schema and data for the given schema',
93+
)
8294
console.error()
8395
console.error('Options:')
8496
console.error(' --no-bail: continue past the first error')
8597
console.error(' -d, --data: use this as the data file (requires --schema)')
8698
console.error(' -s, --schema: use this as the schema (requires --data)')
8799
console.error()
88-
console.error(`By default, the program looks for schema files in ${SCHEMA_BASE}`)
100+
console.error(
101+
`By default, the program looks for schema files in ${SCHEMA_BASE}`,
102+
)
89103
process.exit(1)
90104
}
91105

92106
if ((args.data && !args.schema) || (args.schema && !args.data)) {
93107
console.error('Usage: node validate-compiled-data.js [options] [args]')
94-
console.error('If either --data or --schema are provided, both are required')
108+
console.error(
109+
'If either --data or --schema are provided, both are required',
110+
)
95111
process.exit(1)
96112
}
97113

@@ -145,7 +161,9 @@ function formatError(err, data) {
145161
const dataPath = err.dataPath.replace(/^\./, '')
146162
switch (err.keyword) {
147163
case 'enum': {
148-
contents = `Given value "${get(data, dataPath)}" ${err.message} [${err.params.allowedValues.join(', ')}]`
164+
const value = get(data, dataPath)
165+
const allowed = err.params.allowedValues.join(', ')
166+
contents = `Given value "${value}" ${err.message} [${allowed}]`
149167
break
150168
}
151169
case 'type': {
@@ -156,8 +174,5 @@ function formatError(err, data) {
156174
return JSON.stringify(err, null, 2)
157175
}
158176
}
159-
return [
160-
`Error at ${err.dataPath}:`,
161-
contents,
162-
].join('\n')
177+
return [`Error at ${err.dataPath}:`, contents].join('\n')
163178
}

0 commit comments

Comments
 (0)