diff --git a/.gitignore b/.gitignore index 4bac7bc..55dc4f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,7 @@ node_modules/* dist/* -!dist/.gitexists - -test/screenshots/* -!test/screenshots/.gitexists +temp/* .DS_store *.log diff --git a/gulpfile.js b/gulpfile.js index 58a87ac..83fb0c2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,10 +1,13 @@ -var gulp = require('gulp'); -var webpack = require('webpack-stream'); -var uglify = require('gulp-uglify'); -var path = require('path'); -var mochaPhantomJS = require('gulp-mocha-phantomjs'); -var WrapperPlugin = require('wrapper-webpack-plugin'); -var release = require('gulp-github-release'); +const gulp = require('gulp'); +const gutil = require('gulp-util'); +const webpack = require('webpack-stream'); +const uglify = require('gulp-uglify'); +const path = require('path'); +const fs = require('fs-extra'); +const mochaPhantomJS = require('gulp-mocha-phantomjs'); +const WrapperPlugin = require('wrapper-webpack-plugin'); +const release = require('gulp-github-release'); +const through = require('through2'); var webpackModule = { loaders: [ @@ -25,10 +28,18 @@ var webpackModule = { ] }; -gulp.task('test', function () { +gulp.task('clean', () => { + ['dist','temp','temp/screenshots'].map((dir)=>{ + fs.removeSync(dir); + fs.mkdirSync(dir); + }) +}); + +gulp.task('test', ['make'], function () { return gulp .src('test/index.html') .pipe(mochaPhantomJS({ + reporter: 'nyan', suppressStderr: false, phantomjs: { viewportSize: { @@ -40,7 +51,37 @@ gulp.task('test', function () { localToRemoteUrlAccessEnabled: true } } - })); + })) + .pipe(through.obj((chunk, enc, cb) => { + + const screenshotPath = 'temp/screenshots/'; + const screenshots = fs.readdirSync(screenshotPath); + + let uploadCount = 0; + const isDoneMaybe = () => { + uploadCount++; + if(uploadCount >= screenshots.length) { + cb(null, chunk); + } + } + + screenshots.map((screenshot)=>{ + + let spawn = require('child_process').spawn; + let child = spawn('curl',[ + '--upload-file', + `./${screenshotPath+screenshot}`, + 'https://transfer.sh/' + ]); + + child.stdout.on('data', (buffer) => { + gutil.log('Look at it!!!', gutil.colors.magenta(buffer.toString().replace("\n",''))); + }); + child.stdout.on('end', isDoneMaybe); + + }); + + })) }); gulp.task('default', function() { @@ -69,7 +110,7 @@ gulp.task('default', function() { .pipe(gulp.dest('dist/')); }); -gulp.task('make', function() { +gulp.task('make', ['clean'], function() { return gulp.src('src/app.js') .pipe(webpack({ output: { diff --git a/package.json b/package.json index daad4f5..a20d118 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,11 @@ "document-ready-promise": "^3.0.1", "es6-promise": "^4.0.5", "es6-promise-promise": "1.0.0", + "fs-extra": "^2.0.0", "gulp": "^3.9.1", "gulp-mocha-phantomjs": "^0.12.0", "gulp-uglify": "^1.5.4", + "gulp-util": "^3.0.8", "raw-loader": "^0.5.1", "webpack": "^1.13.1", "webpack-stream": "^3.2.0", @@ -27,7 +29,8 @@ "devDependencies": { "gulp-github-release": "^1.2.0", "mocha": "^2.5.3", - "mocha-phantomjs": "^4.1.0" + "mocha-phantomjs": "^4.1.0", + "through2": "^2.0.3" }, "homepage": "https://lawwrr.github.io/constellation/", "keywords": [ diff --git a/test/test.js b/test/test.js index 84181ae..703f42b 100644 --- a/test/test.js +++ b/test/test.js @@ -44,8 +44,7 @@ describe('Rendering', function() { after(function(){ if (window.callPhantom) { var date = new Date() - var filename = "test/screenshots/" + date.getTime() - console.log("Taking screenshot " + filename) + var filename = "temp/screenshots/" + date.getTime() callPhantom({'screenshot': filename}) } })