Skip to content

Commit

Permalink
lint: fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanashworth committed Jul 7, 2017
1 parent 9c2d866 commit de4d66b
Show file tree
Hide file tree
Showing 10 changed files with 748 additions and 738 deletions.
10 changes: 9 additions & 1 deletion .eslintrc.yml
Expand Up @@ -7,8 +7,16 @@ parserOptions:
sourceType: module
rules:
indent:
- off
- error
- 2
- FunctionDeclaration:
parameters: first
FunctionExpression:
parameters: first
CallExpression:
arguments: first
ArrayExpression: first
ObjectExpression: first
linebreak-style:
- error
- unix
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -47,7 +47,7 @@
"devDependencies": {
"browserify": "^12.0.1",
"chai": "^3.4.0",
"eslint": "^3.11.1",
"eslint": "^4.1.1",
"gulp": "^3.9.0",
"gulp-babel": "^5.2.1",
"gulp-eslint": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/main/bucket-policy.js
Expand Up @@ -100,7 +100,7 @@ export function generateBucketPolicy(policy, bucketName, objectPrefix) {
throw new errors.InvalidBucketNameError(`Invalid bucket name: ${bucketName}`)
}
if (!isValidBucketPolicy(policy)) {
throw new errors.InvalidBucketPolicyError(`Invalid bucket policy: ${policy}` +
throw new errors.InvalidBucketPolicyError(`Invalid bucket policy: ${policy}` +
`(must be 'none', 'readonly', 'writeonly', or 'readwrite')`)
}

Expand Down
98 changes: 49 additions & 49 deletions src/main/minio.js
Expand Up @@ -31,16 +31,16 @@ import path from 'path'
import _ from 'lodash'

import { isValidPrefix, isValidEndpoint, isValidBucketName,
isValidPort, isValidObjectName, isAmazonEndpoint, getScope,
uriEscape, uriResourceEscape, isBoolean, isFunction, isNumber,
isString, isObject, isDate, isArray, pipesetup,
readableStream, isReadableStream, isVirtualHostStyle,
probeContentType } from './helpers.js'
isValidPort, isValidObjectName, isAmazonEndpoint, getScope,
uriEscape, uriResourceEscape, isBoolean, isFunction, isNumber,
isString, isObject, isDate, isArray, pipesetup,
readableStream, isReadableStream, isVirtualHostStyle,
probeContentType } from './helpers.js'

import { signV4, presignSignatureV4, postPresignSignatureV4 } from './signing.js'

import { isValidBucketPolicy, generateBucketPolicy,
parseBucketPolicy } from './bucket-policy'
parseBucketPolicy } from './bucket-policy'

export { Policy } from './bucket-policy'

Expand Down Expand Up @@ -132,7 +132,7 @@ export class Client {

this.regionMap = {}
if (params.region) {
this.region = params.region
this.region = params.region
}

this.minimumPartSize = 5*1024*1024
Expand Down Expand Up @@ -399,9 +399,9 @@ export class Client {
})
let pipe = pipesetup(stream, req)
pipe.on('error', e => {
this.logHTTP(reqOptions, null, e)
cb(e)
})
this.logHTTP(reqOptions, null, e)
cb(e)
})
}
if (region) return _makeRequest(null, region)
this.getBucketRegion(options.bucketName, _makeRequest)
Expand Down Expand Up @@ -944,13 +944,13 @@ export class Client {
// part is not uploaded yet, or md5 mismatch
var stream = fs.createReadStream(filePath, options)
uploader(uploadId, partNumber, stream, length,
data.sha256sum, data.md5sum, (e, etag) => {
if (e) return cb(e)
partsDone.push({part: partNumber, etag})
partNumber++
uploadedSize += length
return cb()
})
data.sha256sum, data.md5sum, (e, etag) => {
if (e) return cb(e)
partsDone.push({part: partNumber, etag})
partNumber++
uploadedSize += length
return cb()
})
})
.on('error', e => cb(e))
},
Expand Down Expand Up @@ -1004,7 +1004,7 @@ export class Client {
// We'll need to shift arguments to the left because of contentType
// and size being optional.
if (isString(size)) {
contentType = size
contentType = size
}

if (typeof stream === 'string' || stream instanceof Buffer) {
Expand Down Expand Up @@ -1126,7 +1126,7 @@ export class Client {
throw new TypeError('maxKeys should be of type "number"')
}
var queries = []
// escape every value in query string, except maxKeys
// escape every value in query string, except maxKeys
if (prefix) {
prefix = uriEscape(prefix)
queries.push(`prefix=${prefix}`)
Expand Down Expand Up @@ -1203,16 +1203,16 @@ export class Client {
if (ended) return readStream.push(null)
// if there are no objects to push do query for the next batch of objects
this.listObjectsQuery(bucketName, prefix, marker, delimiter, 1000)
.on('error', e => readStream.emit('error', e))
.on('data', result => {
if (result.isTruncated) {
marker = result.nextMarker
} else {
ended = true
}
objects = result.objects
readStream._read()
})
.on('error', e => readStream.emit('error', e))
.on('data', result => {
if (result.isTruncated) {
marker = result.nextMarker
} else {
ended = true
}
objects = result.objects
readStream._read()
})
}
return readStream
}
Expand Down Expand Up @@ -1317,16 +1317,16 @@ export class Client {
if (ended) return readStream.push(null)
// if there are no objects to push do query for the next batch of objects
this.listObjectsV2Query(bucketName, prefix, continuationToken, delimiter, 1000)
.on('error', e => readStream.emit('error', e))
.on('data', result => {
if (result.isTruncated) {
continuationToken = result.nextContinuationToken
} else {
ended = true
}
objects = result.objects
readStream._read()
})
.on('error', e => readStream.emit('error', e))
.on('data', result => {
if (result.isTruncated) {
continuationToken = result.nextContinuationToken
} else {
ended = true
}
objects = result.objects
readStream._read()
})
}
return readStream
}
Expand Down Expand Up @@ -1931,16 +1931,16 @@ export class Client {
'Content-MD5': md5sum
}
this.makeRequestStream({method, bucketName, objectName, query, headers},
stream, sha256sum, 200, '', (e, response) => {
if (e) return cb(e)
var etag = response.headers.etag
if (etag) {
etag = etag.replace(/^"/, '').replace(/"$/, '')
}
// Ignore the 'data' event so that the stream closes. (nodejs stream requirement)
response.on('data', () => {})
cb(null, etag)
})
stream, sha256sum, 200, '', (e, response) => {
if (e) return cb(e)
var etag = response.headers.etag
if (etag) {
etag = etag.replace(/^"/, '').replace(/"$/, '')
}
// Ignore the 'data' event so that the stream closes. (nodejs stream requirement)
response.on('data', () => {})
cb(null, etag)
})
}
if (multipart) {
return multipartUploader
Expand Down
16 changes: 8 additions & 8 deletions src/main/object-uploader.js
Expand Up @@ -209,16 +209,16 @@ export default class ObjectUploader extends Transform {
// completing the multipart upload.
this.client.completeMultipartUpload(this.bucketName, this.objectName, this.id,
this.etags, (err, etag) => {
if (err) return callback(err)
if (err) return callback(err)

// Call our callback on the next tick to allow the streams infrastructure
// to finish what its doing before we continue.
process.nextTick(() => {
this.callback(null, etag)
})
// Call our callback on the next tick to allow the streams infrastructure
// to finish what its doing before we continue.
process.nextTick(() => {
this.callback(null, etag)
})

callback()
})
callback()
})
}

}
14 changes: 7 additions & 7 deletions src/main/signing.js
Expand Up @@ -49,9 +49,9 @@ function getCanonicalRequest(method, path, headers, signedHeaders, hashedPayload
throw new TypeError('hashedPayload should be of type "string"')
}
var headersArray = signedHeaders.reduce((acc, i) => {
acc.push(`${i.toLowerCase()}:${headers[i]}`)
return acc
}, [])
acc.push(`${i.toLowerCase()}:${headers[i]}`)
return acc
}, [])

var requestResource = path.split('?')[0]
var requestQuery = path.split('?')[1]
Expand Down Expand Up @@ -123,8 +123,8 @@ function getSignedHeaders(headers) {

var ignoredHeaders = ['authorization', 'content-length', 'content-type', 'user-agent']
return _.map(headers, (v, header) => header)
.filter(header => ignoredHeaders.indexOf(header) === -1)
.sort()
.filter(header => ignoredHeaders.indexOf(header) === -1)
.sort()
}

// returns the key used for calculating signature
Expand Down Expand Up @@ -211,7 +211,7 @@ export function signV4(request, accessKey, secretKey, region) {

var signedHeaders = getSignedHeaders(request.headers)
var canonicalRequest = getCanonicalRequest(request.method, request.path, request.headers,
signedHeaders, sha256sum)
signedHeaders, sha256sum)
var stringToSign = getStringToSign(canonicalRequest, requestDate, region)
var signingKey = getSigningKey(requestDate, region, secretKey)
var credential = getCredential(accessKey, region, requestDate)
Expand Down Expand Up @@ -278,7 +278,7 @@ export function presignSignatureV4(request, accessKey, secretKey, region, reques
var path = resource + '?' + query

var canonicalRequest = getCanonicalRequest(request.method, path,
request.headers, signedHeaders, hashedPayload)
request.headers, signedHeaders, hashedPayload)

var stringToSign = getStringToSign(canonicalRequest, requestDate, region)
var signingKey = getSigningKey(requestDate, region, secretKey)
Expand Down
38 changes: 19 additions & 19 deletions src/main/transformers.js
Expand Up @@ -40,25 +40,25 @@ export function getConcater(parser, emitError) {
}

return Through2({objectMode},
function (chunk, enc, cb) {
bufs.push(chunk)
cb()
}, function (cb) {
if (emitError) {
cb(parser(Buffer.concat(bufs).toString()))
// cb(e) would mean we have to emit 'end' by explicitly calling this.push(null)
this.push(null)
return
}
if (bufs.length) {
if (parser) {
this.push(parser(Buffer.concat(bufs).toString()))
} else {
this.push(Buffer.concat(bufs))
}
}
cb()
})
function (chunk, enc, cb) {
bufs.push(chunk)
cb()
}, function (cb) {
if (emitError) {
cb(parser(Buffer.concat(bufs).toString()))
// cb(e) would mean we have to emit 'end' by explicitly calling this.push(null)
this.push(null)
return
}
if (bufs.length) {
if (parser) {
this.push(parser(Buffer.concat(bufs).toString()))
} else {
this.push(Buffer.concat(bufs))
}
}
cb()
})
}

// Generates an Error object depending on http statusCode and XML body
Expand Down

0 comments on commit de4d66b

Please sign in to comment.