From 7569e66d92963241ef4d160d6fca787fefba387f Mon Sep 17 00:00:00 2001 From: "Frederick F. Kautz IV" Date: Sat, 23 May 2015 19:27:02 -0700 Subject: [PATCH] Setting up babel for ES6 compilation --- .gitignore | 7 +++++++ gulpfile.js | 39 +++++++++++++++++++++++++++++++++++++++ package.json | 15 ++++++++++++--- src/minio.js | 7 +++++++ test/test.js | 18 ++++++++++++++++++ 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 gulpfile.js create mode 100644 src/minio.js create mode 100644 test/test.js diff --git a/.gitignore b/.gitignore index 123ae94d..c9da9a30 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,10 @@ build/Release # Dependency directory # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git node_modules + +# IDEA +/.idea/ +/build/ +*.iml + +/dist/ diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..42e0b955 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,39 @@ +var gulp = require('gulp') +var babel = require('gulp-babel') +var mocha = require('gulp-mocha') +var concat = require('gulp-concat') +var sourcemaps = require('gulp-sourcemaps') +//var sourcemaps = require('gulp-sourcemaps') + +gulp.task('default', ['test'], function() { +}) + +gulp.task('compile', function(cb) { + gulp.src('src/**/*.js') + .pipe(sourcemaps.init()) + .pipe(concat('minio.js')) + .pipe(babel()) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest('dist/main')) + .on('end', function() { + cb() + }) +}) + +gulp.task('test:compile', function(cb) { + gulp.src('test/**/*.js') + .pipe(sourcemaps.init()) + .pipe(concat('minio-test.js')) + .pipe(babel()) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest('dist/test')) + .on('end', function() { + cb() + }) +}) + +gulp.task('test',['compile', 'test:compile'], function () { + gulp.src('dist/test/*.js', {read: false}) + .pipe(mocha({reporter: 'nyan'})) +}) + diff --git a/package.json b/package.json index 6d76cd49..897bc50a 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,10 @@ "name": "minio", "version": "0.0.2", "description": "S3 compatible object storage client", - "main": "index.js", + "main": "./dist/main/minio.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "preinstall": "gulp compile", + "test": "gulp test" }, "repository": { "type": "git", @@ -15,5 +16,13 @@ "bugs": { "url": "https://github.com/minio/objectstorage-js/issues" }, - "homepage": "https://github.com/minio/objectstorage-js#readme" + "homepage": "https://github.com/minio/objectstorage-js#readme", + "dependencies": {}, + "devDependencies": { + "gulp-babel": "^5.1.0", + "gulp-concat": "^2.5.2", + "gulp-mocha": "^2.1.0", + "gulp-sourcemaps": "^1.5.2", + "source-map-support": "^0.2.10" + } } diff --git a/src/minio.js b/src/minio.js new file mode 100644 index 00000000..95f8e180 --- /dev/null +++ b/src/minio.js @@ -0,0 +1,7 @@ +class Minio { + getClient() { + return "hello"; + } +} +var inst = new Minio(); +module.exports = inst; diff --git a/test/test.js b/test/test.js new file mode 100644 index 00000000..0f2b054a --- /dev/null +++ b/test/test.js @@ -0,0 +1,18 @@ +require('source-map-support').install(); + +var assert = require('assert'); +var minio = require('../..'); + +describe('Object Storage Client', function () { + "use strict"; + describe("#getClient()", function () { + it('should return a client', function () { + var client = minio.getClient(); + assert.equal('hello', client); + }) + it('should return index when the value is not present', function () { + assert.equal(0, [2, 3, 4].indexOf(2)) + }) + }) + } +)