Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit 4416a12

Browse files
committed
Run prettier on src and test js files
1 parent f5c43e1 commit 4416a12

File tree

5 files changed

+30
-45
lines changed

5 files changed

+30
-45
lines changed

src/commands/functions/build.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const fs = require('fs')
2-
const {flags} = require('@oclif/command')
2+
const { flags } = require('@oclif/command')
33
const Command = require('@netlify/cli-utils')
4-
const {zipFunctions} = require('@netlify/zip-it-and-ship-it')
4+
const { zipFunctions } = require('@netlify/zip-it-and-ship-it')
55

66
class FunctionsBuildCommand extends Command {
77
async run() {
8-
const {flags, args} = this.parse(FunctionsBuildCommand)
9-
const {config} = this.netlify
8+
const { flags, args } = this.parse(FunctionsBuildCommand)
9+
const { config } = this.netlify
1010

1111
const src = flags.src || config.build.functionsSource
1212
const dst = flags.functions || config.build.functions
@@ -26,10 +26,10 @@ class FunctionsBuildCommand extends Command {
2626
process.exit(1)
2727
}
2828

29-
fs.mkdirSync(dst, {recursive: true})
29+
fs.mkdirSync(dst, { recursive: true })
3030

3131
this.log('Building functions')
32-
zipFunctions(src, dst, {skipGo: true})
32+
zipFunctions(src, dst, { skipGo: true })
3333
this.log('Functions buildt to ', dst)
3434
}
3535
}
@@ -40,12 +40,12 @@ FunctionsBuildCommand.description = `build functions locally
4040
FunctionsBuildCommand.flags = {
4141
functions: flags.string({
4242
char: 'f',
43-
description: 'Specify a functions folder to build to',
43+
description: 'Specify a functions folder to build to'
4444
}),
4545
src: flags.string({
4646
char: 's',
47-
description: 'Specify the source folder for the functions',
48-
}),
47+
description: 'Specify the source folder for the functions'
48+
})
4949
}
5050

5151
module.exports = FunctionsBuildCommand

src/commands/functions/create.js

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require('fs')
22
const path = require('path')
3-
const {flags} = require('@oclif/command')
3+
const { flags } = require('@oclif/command')
44
const Command = require('@netlify/cli-utils')
55

66
const template = `async function hello() {
@@ -19,76 +19,61 @@ exports.handler = async function(event, context) {
1919

2020
class FunctionsCreateCommand extends Command {
2121
async run() {
22-
const {flags, args} = this.parse(FunctionsCreateCommand)
23-
const {name} = args
24-
const {config} = this.netlify
22+
const { flags, args } = this.parse(FunctionsCreateCommand)
23+
const { name } = args
24+
const { config } = this.netlify
2525

2626
this.log(`Creating function ${name}`)
2727

28-
const functionsDir =
29-
flags.functions || (config.build && config.build.functions)
28+
const functionsDir = flags.functions || (config.build && config.build.functions)
3029
if (!functionsDir) {
31-
this.log(
32-
'No functions folder specified in netlify.toml or as an argument'
33-
)
30+
this.log('No functions folder specified in netlify.toml or as an argument')
3431
process.exit(1)
3532
}
3633

3734
if (!fs.existsSync(functionsDir)) {
3835
fs.mkdir(functionsDir)
3936
}
4037

41-
const functionPath = flags.dir ?
42-
path.join(functionsDir, name, name + '.js') :
43-
path.join(functionsDir, name + '.js')
38+
const functionPath = flags.dir ? path.join(functionsDir, name, name + '.js') : path.join(functionsDir, name + '.js')
4439
if (fs.existsSync(functionPath)) {
4540
this.log(`Function ${functionPath} already exists`)
4641
process.exit(1)
4742
}
4843

4944
if (flags.dir) {
5045
const fnFolder = path.join(functionsDir, name)
51-
if (
52-
fs.existsSync(fnFolder + '.js') &&
53-
fs.lstatSync(fnFolder + '.js').isFile()
54-
) {
55-
this.log(
56-
`A single file version of the function ${name} already exists at ${fnFolder}.js`
57-
)
46+
if (fs.existsSync(fnFolder + '.js') && fs.lstatSync(fnFolder + '.js').isFile()) {
47+
this.log(`A single file version of the function ${name} already exists at ${fnFolder}.js`)
5848
process.exit(1)
5949
}
6050

6151
try {
62-
fs.mkdirSync(fnFolder, {recursive: true})
52+
fs.mkdirSync(fnFolder, { recursive: true })
6353
} catch (e) {
6454
// Ignore
6555
}
6656
} else if (fs.existsSync(functionPath.replace(/\.js/, ''))) {
67-
this.log(
68-
`A folder version of the function ${name} alreadt exists at ${functionPath.replace(
69-
/\.js/,
70-
''
71-
)}`
72-
)
57+
this.log(`A folder version of the function ${name} alreadt exists at ${functionPath.replace(/\.js/, '')}`)
7358
process.exit(1)
7459
}
7560

7661
fs.writeFileSync(functionPath, template)
7762
}
7863
}
7964

80-
FunctionsCreateCommand.args = [{name: 'name'}]
65+
FunctionsCreateCommand.args = [{ name: 'name' }]
8166

8267
FunctionsCreateCommand.description = `create a new function locally
8368
`
8469

8570
FunctionsCreateCommand.examples = ['netlify functions:create hello-world']
8671

8772
FunctionsCreateCommand.flags = {
88-
functions: flags.string({char: 'f', description: 'functions folder'}),
73+
functions: flags.string({ char: 'f', description: 'functions folder' }),
8974
dir: flags.boolean({
9075
char: 'd',
91-
description: 'create function as a directory',
92-
}),
76+
description: 'create function as a directory'
77+
})
9378
}
9479
module.exports = FunctionsCreateCommand

src/commands/functions/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const chalk = require('chalk')
2-
const {Command} = require('@oclif/command')
2+
const { Command } = require('@oclif/command')
33

44
function showHelp(command) {
5-
execSync(`netlify ${command} --help`, {stdio: [0, 1, 2]})
5+
execSync(`netlify ${command} --help`, { stdio: [0, 1, 2] })
66
}
77

88
function isEmptyCommand(flags, args) {
@@ -22,7 +22,7 @@ function hasArgs(args) {
2222

2323
class FunctionsCommand extends Command {
2424
async run() {
25-
const {flags, args} = this.parse(FunctionsCommand)
25+
const { flags, args } = this.parse(FunctionsCommand)
2626
// run help command if no args passed
2727
if (isEmptyCommand(flags, args)) {
2828
showHelp(this.id)
@@ -38,7 +38,7 @@ The ${name} command will help you manage the functions in this site
3838
`
3939
FunctionsCommand.examples = [
4040
'netlify functions:create --name function-xyz --runtime nodejs',
41-
'netlify functions:update --name function-abc --timeout 30s',
41+
'netlify functions:update --name function-abc --timeout 30s'
4242
]
4343

4444
// TODO make visible once implementation complete

src/commands/functions/serve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Extra documentation goes here
1212
`
1313

1414
FunctionsServeCommand.flags = {
15-
name: flags.string({char: 'n', description: 'name to print'}),
15+
name: flags.string({ char: 'n', description: 'name to print' })
1616
}
1717

1818
// TODO make visible once implementation complete

src/commands/functions/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Extra documentation goes here
1212
`
1313

1414
FunctionsUpdateCommand.flags = {
15-
name: flags.string({char: 'n', description: 'name to print'}),
15+
name: flags.string({ char: 'n', description: 'name to print' })
1616
}
1717

1818
// TODO make visible once implementation complete

0 commit comments

Comments
 (0)