diff --git a/gulpfile.js b/gulpfile.js index 9f6af992..c304aad2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,6 +16,7 @@ const babel = require('gulp-babel') const gulp = require('gulp') +const gulpIf = require('gulp-if') const sourcemaps = require('gulp-sourcemaps') const fs = require('fs') @@ -59,11 +60,18 @@ exports.test = gulp.series(testCompile, () => { })) }) +function isFixed(file) { + return file.eslint != null && file.eslint.fixed +} + exports.lint = () => { + const hasFixFlag = process.argv.slice(2).includes('--fix') return gulp.src(['src/**/*.js', 'gulpfile.js']) - .pipe(eslint()) + .pipe(eslint({fix: hasFixFlag})) .pipe(eslint.format()) .pipe(eslint.failAfterError()) + // if fixed, write the file to dest + .pipe(gulpIf(isFixed, gulp.dest('src/'))) } exports.functionalTest = gulp.series(testCompile, () => { diff --git a/package.json b/package.json index 8e3baaa0..d6312786 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "compile": "gulp compile", "test": "gulp test", "lint": "gulp lint", + "lint-fix": "gulp lint --fix", "prepublishOnly": "gulp test", "functional": "gulp functionalTest", "browserify": "gulp browserify", @@ -56,6 +57,7 @@ "gulp": "^4.0.2", "gulp-babel": "^8.0.0", "gulp-eslint": "^6.0.0", + "gulp-if": "^3.0.0", "gulp-mocha": "^6.0.0", "gulp-sourcemaps": "^2.6.5", "mocha": "^6.2.0", diff --git a/src/main/minio.js b/src/main/minio.js index c59333b8..c8718266 100644 --- a/src/main/minio.js +++ b/src/main/minio.js @@ -1253,7 +1253,7 @@ export class Client { if (!isObject(listQueryOpts)) { throw new TypeError('listQueryOpts should be of type "object"') } - + if (!isString(Delimiter)) { throw new TypeError('Delimiter should be of type "string"') } @@ -1639,18 +1639,15 @@ export class Client { const encoder = new TextEncoder() async.eachSeries(result.listOfList, (list, callback) => { - var deleteObjects={"Delete":[{Quiet:true}], } + var objects=[] list.forEach(function(value){ - //Backward Compatibility - let entry - if(isObject(value)){ - entry={"Object": [{"Key": value.name, "VersionId":value.versionId}]} - }else{ - entry={"Object": [{"Key": value}]} + if (isObject(value)) { + objects.push({"Key": value.name, "VersionId": value.versionId}) + } else { + objects.push({"Key": value}) } - - deleteObjects["Delete"].push(entry) }) + let deleteObjects = {"Delete": {"Quiet": true, "Object": objects}} const builder = new xml2js.Builder({ headless: true }) let payload = builder.buildObject(deleteObjects) payload = encoder.encode(payload) @@ -2352,7 +2349,7 @@ export class Client { const builder = new xml2js.Builder({ headless:true,renderOpts:{'pretty':false},}) let payload = builder.buildObject(taggingConfig) payload = encoder.encode(payload) - + const requestOptions = { method, bucketName, query, headers } if(objectName){ diff --git a/src/test/functional/functional-tests.js b/src/test/functional/functional-tests.js index 5234521f..e720cb5c 100644 --- a/src/test/functional/functional-tests.js +++ b/src/test/functional/functional-tests.js @@ -119,7 +119,7 @@ describe('functional tests', function() { } var tmpDir = os.tmpdir() - + function readableStream(data) { var s = new stream.Readable() s._read = () => {} @@ -127,7 +127,7 @@ describe('functional tests', function() { s.push(null) return s } - + var traceStream // FUNCTIONAL_TEST_TRACE env variable contains the path to which trace @@ -1200,7 +1200,7 @@ describe('functional tests', function() { .catch(done) }) - step(`removeObjects with non latin charactes`, done => { + step(`removeObjects with non latin characters`, done => { client.removeObjects(bucketName, ['fileΩ']) .then(() => done()) .catch(done) @@ -1573,7 +1573,7 @@ describe('functional tests', function() { describe('Versioning tests on a bucket for Deletion of Multiple versions', function () { //Isolate the bucket/object for easy debugging and tracking. - const versionedBucketName = "minio-js-test-version-" + uuid.v4() + const versionedBucketName = "minio-js-test-version-" + uuid.v4() const versioned_100kbObjectName = 'datafile-100-kB' const versioned_100kb_Object = dataDir ? fs.readFileSync(dataDir + '/' + versioned_100kbObjectName) : Buffer.alloc(100 * 1024, 0) @@ -1653,7 +1653,7 @@ describe('functional tests', function() { }) describe('Bucket Tags API', ()=>{ - //Isolate the bucket/object for easy debugging and tracking. + // Isolate the bucket/object for easy debugging and tracking. const tagsBucketName = "minio-js-test-tags-" + uuid.v4() before((done) => client.makeBucket(tagsBucketName, '', done)) after((done) => client.removeBucket(tagsBucketName, done)) @@ -1661,12 +1661,14 @@ describe('functional tests', function() { describe('set, get and remove Tags on a bucket', function () { step(`Set tags on a bucket_bucketName:${tagsBucketName}`, done => { client.setBucketTagging(tagsBucketName, {'test-tag-key':'test-tag-value'}, (err) => { + if (err && err.code === 'NotImplemented') return done() if (err) return done(err) done() }) }) step(`Get tags on a bucket_bucketName:${tagsBucketName}`, done => { client.getBucketTagging(tagsBucketName, (err, tagList) => { + if (err && err.code === 'NotImplemented') return done() if (err) return done(err) if(isArray(tagList)) { done() @@ -1676,6 +1678,7 @@ describe('functional tests', function() { step(`remove Tags on a bucket_bucketName:${tagsBucketName}`, done => { client.removeBucketTagging(tagsBucketName, (err) => { + if (err && err.code === 'NotImplemented') return done() if (err) return done(err) done() }) @@ -1706,6 +1709,7 @@ describe('functional tests', function() { step(`putObjectTagging object_bucketName:${tagsBucketName}, objectName:${tagObjName},`, done => { client.setObjectTagging(tagsBucketName, tagObjName, {'test-tag-key-obj':'test-tag-value-obj'}, (err) => { + if (err && err.code === 'NotImplemented') return done() if (err) return done(err) done() }) @@ -1713,6 +1717,7 @@ describe('functional tests', function() { step(`getObjectTagging object_bucketName:${tagsBucketName}, objectName:${tagObjName},`, done => { client.getObjectTagging(tagsBucketName, tagObjName, (err, tagList) => { + if (err && err.code === 'NotImplemented') return done() if (err) return done(err) if(isArray(tagList)) { done() @@ -1722,6 +1727,7 @@ describe('functional tests', function() { step(`removeObjectTagging on an object_bucketName:${tagsBucketName}, objectName:${tagObjName},`, done => { client.removeObjectTagging(tagsBucketName, tagObjName, (err) => { + if (err && err.code === 'NotImplemented') return done() if (err) return done() done() }) @@ -1800,6 +1806,7 @@ describe('functional tests', function() { if(isVersioningSupported) { client.removeObjectTagging(tagsVersionedBucketName, tagObjName, {versionId:versionId},(err) => { + if (err && err.code === 'NotImplemented') return done() if (err) return done() done() }) @@ -2289,8 +2296,10 @@ describe('functional tests', function() { isEncryptionSupported = false return done() } + if (err && err.code === 'ServerSideEncryptionConfigurationNotFoundError') { + return done() + } if (err) return done(err) - done() }) })