Skip to content

Commit

Permalink
Merge branch 'master' into category-in-build
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdove1 committed Jun 17, 2019
2 parents 4fc2275 + 5ad3298 commit a544065
Show file tree
Hide file tree
Showing 16 changed files with 170 additions and 1,399 deletions.
62 changes: 8 additions & 54 deletions gulpfile.js
Expand Up @@ -4,15 +4,9 @@ var uglify = require('gulp-uglify');
var babel = require('gulp-babel');
var filesExist = require('files-exist');
var maps = require('gulp-sourcemaps');
var babelify = require("babelify");
var browserify = require('browserify');
var gulpSequence = require('gulp-sequence');
var source = require('vinyl-source-stream');
var fs = require('fs');


var files = [
'./source/getCORSCss.js',
'./source/jquery.canvaswrapper.js',
'./source/jquery.colorhelpers.js',
'./source/jquery.flot.js',
Expand All @@ -38,64 +32,24 @@ var files = [
'./source/jquery.flot.legend.js'
];

gulp.task('modify jquery.flot.composeImages.js first', async function() {
fs.readFile('./source/jquery.flot.composeImages.js', (err, data) => {
if (err) {
return console.log(err);
}
var content = data.toString();
var new_content = content.replace(`import {getCrossDomainCSSRules} from "./getCORSCss";`,`//import {getCrossDomainCSSRules} from "./getCORSCss";`);
fs.writeFile('./source/jquery.flot.composeImages.js', new_content, (err) => {
if (err) {
return console.error(err);
}
})
});
});

gulp.task('build_flot_source', function() {
return gulp.src(filesExist(files, { exceptionMessage: 'Missing file' }))
.pipe(concat('jquery.flot.js'))
.pipe(gulp.dest('dist/source'));
});

gulp.task('build_flot_minified_start', function() {
gulp.task('build_flot_minified', function() {
return gulp.src(filesExist(files, { exceptionMessage: 'Missing file' }))
.pipe(concat('jquery.flot.js'))
.pipe(gulp.dest('dist/es5'));
});

gulp.task('browserify_flot', function() {
var b = browserify({
entries: "dist/es5/jquery.flot.js"
});
return b.transform(babelify, {presets: ["@babel/preset-env"]})
.bundle()
.pipe(source("jquery.flot.js"))
.pipe(gulp.dest("dist/es5"));
});

gulp.task('build_flot_minified_end', function() {
return gulp.src(filesExist("dist/es5/jquery.flot.js", { exceptionMessage: 'Missing file' }))
.pipe(maps.init())
.pipe(babel({
"presets": [
"@babel/preset-env"
]
}))
.pipe(concat('jquery.flot.js'))
.pipe(uglify())
.pipe(maps.write('./'))
.pipe(gulp.dest('dist/es5'));
});

gulp.task('modify jquery.flot.composeImages.js in the end', async function() {
fs.readFile('./source/jquery.flot.composeImages.js', (err, data) => {
if (err) {
return console.log(err);
}
var content = data.toString();
var new_content = content.replace(`//import {getCrossDomainCSSRules} from "./getCORSCss";`,`import {getCrossDomainCSSRules} from "./getCORSCss";`);
fs.writeFile('./source/jquery.flot.composeImages.js', new_content, (err) => {
if (err) {
return console.error(err);
}
})
});
});

gulp.task('build', gulp.series('modify jquery.flot.composeImages.js first', 'build_flot_source', 'build_flot_minified_start', 'browserify_flot', 'build_flot_minified_end', 'modify jquery.flot.composeImages.js in the end'));
gulp.task('build', gulp.series('build_flot_source', 'build_flot_minified'));
11 changes: 3 additions & 8 deletions karma.conf.js
Expand Up @@ -59,13 +59,12 @@ module.exports = function(config) {

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine-jquery', 'jasmine', 'browserify'],
frameworks: ['jasmine-jquery', 'jasmine'],

// list of files / patterns to load in the browser
files: sources.concat([
'node_modules/webcharts-development-settings/testsUtils/*.js',
{ pattern: 'tests/svgstyle.css', included: true, served: true },
{ pattern: 'tests/corscss.css', included: true, served: true },
'tests/*.Test.js'
]),

Expand All @@ -76,13 +75,9 @@ module.exports = function(config) {
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'*.js': ['eslint'],
'tests/**/*.js': ['eslint'],
'tests/getCORSCss.Test.js': ['eslint', 'browserify'],
'source/*.js' : ['browserify'],
},
browserify: {
transform: [ ['babelify', {'presets': ["@babel/preset-env"]}]]
'tests/**/*.js': ['eslint']
},

eslint: {
stopOnError: config.stopOnEsLintError ? true : false,
showWarnings: true,
Expand Down

0 comments on commit a544065

Please sign in to comment.