Skip to content

Commit

Permalink
upgrade npm packages to the latest one
Browse files Browse the repository at this point in the history
  • Loading branch information
hsnaydd committed May 18, 2021
1 parent 8226f1b commit 2619588
Show file tree
Hide file tree
Showing 5 changed files with 3,246 additions and 2,803 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "google",
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"globals": {},
"rules": {
"strict": 0,
Expand Down
86 changes: 47 additions & 39 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,74 @@

const gulp = require('gulp');
const del = require('del');
const runSequence = require('run-sequence');
const browserSync = require('browser-sync');
const gulpLoadPlugins = require('gulp-load-plugins');
const lazypipe = require('lazypipe');
const eslint = require('gulp-eslint');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const header = require('gulp-header');
const babel = require('gulp-babel');

const $ = gulpLoadPlugins();
const reload = browserSync.reload;
const pkg = require('./package.json');
const today = $.util.date('dd-mm-yyyy HH:MM');

const browserSyncConfigs = {
notify: false,
// Disable open automatically when Browsersync starts.
open: false,
server: ['./'],
port: 3000
};
const [todayDateISO, todayTimeISO] = new Date().toISOString().split('T');
const [todayYear, todayMonth, todayDay] = todayDateISO.split('-');
const [todayHour, todayMinute] = todayTimeISO.split(':');
const today = `${todayDay}-${todayMonth}-${todayYear} ${todayHour}:${todayMinute}`;

const banner = [
'/*!',
' * MoveTo - ' + pkg.description,
' * Version ' + pkg.version + ' (' + today + ')',
' * Licensed under ' + pkg.license,
' * Copyright ' + $.util.date('yyyy') + ' ' + pkg.author,
' * Copyright ' + todayYear + ' ' + pkg.author,
' */\n\n'
].join('\n');


gulp.task('scripts:lint', (cb) => {
function jsLint() {
return gulp.src('src/**/*.js')
.pipe($.eslint())
.pipe($.eslint.format())
.pipe(browserSync.active ? $.util.noop() : $.eslint.failOnError());
});
.pipe(eslint())
.pipe(eslint.format())
.pipe(browserSync.active ? () => undefined : eslint.failOnError());
}

gulp.task('scripts', ['scripts:lint'], () => {
function jsMain(cb) {
const scriptsMinChannel = lazypipe()
.pipe($.uglify)
.pipe($.rename, {suffix: '.min'})
.pipe($.header, banner)
.pipe(uglify)
.pipe(rename, {suffix: '.min'})
.pipe(header, banner)
.pipe(gulp.dest, 'dist/');

return gulp.src('src/**/*.js')
.pipe($.babel({presets: ['@babel/preset-env']}))
.pipe($.header(banner))
.pipe(babel({ presets: ['@babel/preset-env'] }))
.pipe(header(banner))
.pipe(gulp.dest('dist'))
.pipe(scriptsMinChannel());
});
.pipe(scriptsMinChannel())
.on('end', cb);
}

function reload(cb) {
browserSync.reload();
cb();
}

function serve() {
browserSync.init({
ghostMode: false,
notify: false,
server: ['./'],
port: 3000
});

gulp.watch('src/**/*.js', gulp.series('scripts', reload));
}

gulp.task('scripts:lint', jsLint);
gulp.task('scripts:main', jsMain);
gulp.task('scripts', gulp.series('scripts:lint', 'scripts:main'));

gulp.task('clean:dist', () => del(['dist/*'], {dot: true}));
gulp.task('clean:dist', () => del(['dist/*'], { dot: true }));

gulp.task('build', (cb) =>
runSequence(
['clean:dist'],
['scripts'],
cb
)
);
gulp.task('build', gulp.series('clean:dist', 'scripts'));

gulp.task('serve', () => {
browserSync(browserSyncConfigs);
gulp.watch(['src/**/*.js'], ['scripts', reload]);
});
gulp.task('serve', serve);
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,26 @@
"node": ">=8.9.4"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"ava": "^2.2.0",
"babel-eslint": "^10.0.2",
"browser-sync": "^2.26.7",
"del": "^5.0.0",
"eslint": "^6.1.0",
"eslint-config-google": "^0.13.0",
"gulp": "^3.9.1",
"@ava/babel": "^1.0.1",
"@babel/core": "^7.14.3",
"@babel/eslint-parser": "^7.14.3",
"@babel/preset-env": "^7.14.2",
"ava": "^3.15.0",
"browser-sync": "^2.26.14",
"del": "^6.0.0",
"eslint": "^7.26.0",
"eslint-config-google": "^0.14.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-eslint": "^6.0.0",
"gulp-header": "^2.0.9",
"gulp-load-plugins": "^2.0.0",
"gulp-rename": "^1.4.0",
"gulp-rename": "^2.0.0",
"gulp-uglify": "^3.0.1",
"gulp-util": "^3.0.8",
"jsdom": "15.1.1",
"jsdom": "16.5.3",
"jsdom-global": "3.0.2",
"lazypipe": "^1.0.1",
"run-sequence": "^2.2.1"
}
"lazypipe": "^1.0.1"
},
"ava": {
"babel": true
}
}
5 changes: 2 additions & 3 deletions src/moveTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ const MoveTo = (() => {

const href = dom.getAttribute('href') || dom.getAttribute('data-target');
// The element to be scrolled
const target = (href && href !== '#')
? document.getElementById(href.substring(1))
: document.body;
const target =
(href && href !== '#') ? document.getElementById(href.substring(1)) : document.body;
const options = mergeObject(this.options, _getOptionsFromTriggerDom(dom, this.options));

if (typeof callback === 'function') {
Expand Down
Loading

0 comments on commit 2619588

Please sign in to comment.