Skip to content

Commit

Permalink
Update deps and optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
illvart committed Sep 1, 2020
1 parent 22c6193 commit cbeaf33
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 394 deletions.
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
patreon: illvart
custom: https://buymeacoffee.com/illvart
# github: illvart
custom: ['https://www.paypal.me/illvart']
14 changes: 5 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
language: node_js
node_js:
- '13'
- node

os:
- linux

sudo: false

branches:
only:
- master

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s
- export PATH=$HOME/.yarn/bin:$PATH
- export PATH="$HOME/.yarn/bin:$PATH"

cache:
yarn: true
directories:
- node_modules
cache: yarn

install:
- yarn install
- yarn install --frozen-lockfile

script:
- yarn run format
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Muhammad Nur Fuad (illvart)
Copyright (c) 2020 illvart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
39 changes: 23 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"name": "gatsby-plugin-minify-html",
"description": "A Gatsby plugin for minify HTML files",
"version": "1.0.1",
"author": "Muhammad Nur Fuad <illvart.com@gmail.com> (https://illvart.com)",
"description": "A Gatsby plugin for minify HTML files",
"main": "index.js",
"author": {
"name": "illvart",
"email": "illvart@protonmail.com",
"url": "https://illvart.xyz"
},
"license": "MIT",
"homepage": "https://github.com/illvart/gatsby-plugin-minify-html#readme",
"repository": {
Expand All @@ -12,7 +17,6 @@
"bugs": {
"url": "https://github.com/illvart/gatsby-plugin-minify-html/issues"
},
"main": "index.js",
"keywords": [
"gatsby",
"gatsby-plugin",
Expand All @@ -27,24 +31,27 @@
"optimize",
"optimizer"
],
"dependencies": {
"glob": "^7.1.6",
"html-minifier": "^4.0.0"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
"prettier": "^1.19.1"
"scripts": {
"format": "prettier --check \"./**/*.{js,json,yml}\" --write",
"lint": "eslint --ext .js .",
"lint:fix": "eslint --ext .js --fix ."
},
"prettier": {
"printWidth": 120,
"singleQuote": true,
"bracketSpacing": false,
"trailingComma": "es5"
"arrowParens": "always",
"trailingComma": "all",
"semi": true
},
"scripts": {
"format": "prettier --check --write \"./**/*.js\"",
"lint": "eslint \"./**/*.js\""
"dependencies": {
"glob": "^7.1.6",
"html-minifier": "^4.0.0"
},
"devDependencies": {
"eslint": "^7.8.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"prettier": "^2.1.1"
}
}
4 changes: 2 additions & 2 deletions src/minify-html-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function onPostBuild(args, pluginOptions = {}) {
const minifyTotal = `Minify HTML files at public directory, total HTML files ${files.length}`;
console.info(options.debug ? `${minifyTotal}:` : `${minifyTotal}.`);

const minified = files.map(async file => {
const minified = files.map(async (file) => {
const data = await readFileAsync(file, 'utf8');
return new Promise((resolve, reject) => {
let minify;
Expand All @@ -50,7 +50,7 @@ async function onPostBuild(args, pluginOptions = {}) {
}
const reduced = (((data.length - minify.length) / data.length) * 100).toFixed(2);

fs.writeFile(file, minify, err => {
fs.writeFile(file, minify, (err) => {
if (err) {
reject();
console.error(`Minify HTML error on write file:\n\n${err}`);
Expand Down
6 changes: 3 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const isObject = val => val !== null && typeof val === 'object';
const isBoolean = val => val === false || val === true;
const isObject = (val) => val !== null && typeof val === 'object';
const isBoolean = (val) => val === false || val === true;

const deepMerge = (target = {}, source = {}) => {
Object.keys(source).forEach(key => {
Object.keys(source).forEach((key) => {
if (isObject(source[key])) {
if (!target[key] || !isObject(target[key])) {
target[key] = source[key];
Expand Down
Loading

0 comments on commit cbeaf33

Please sign in to comment.