Skip to content

Commit

Permalink
Merge pull request #3 from posthtml/milestone-2.0.0
Browse files Browse the repository at this point in the history
Milestone 2.0.0
  • Loading branch information
Scrum committed Aug 28, 2020
2 parents a120a31 + f8d9c27 commit 0e5bf3e
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 47 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
@@ -1,8 +1,8 @@
language: node_js
node_js:
- node
- 6
- 4
- 'node'
- 'lts/*'
- '10'
cache:
directories:
- node_modules
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,11 @@
✔ output changes to CHANGELOG.md
ml/posthtml-load-config/compare/v1.0.0...v2.0.0) (2020-08-28)


### Bug Fixes

* prepare plugin with empty options, close [#2](https://github.com/posthtml/posthtml-load-config/issues/2) ([5a836b7](https://github.com/posthtml/posthtml-load-config/commit/5a836b73bd55587eb80815c0edd666e86e3bfe18))
* resolve cwd path to config ([7318071](https://github.com/posthtml/posthtml-load-config/commit/73180714e50e60df58ae78ae06f214c6f2668171))



6 changes: 2 additions & 4 deletions index.js
Expand Up @@ -35,7 +35,7 @@ module.exports = function posthtmlrc (ctx, path, options) {
const defaults = { cwd: process.cwd(), env: process.env.NODE_ENV }

ctx = assign(defaults, ctx)
path = path || process.cwd()
path = path || ctx.cwd
options = assign({}, options)

if (ctx.env === undefined) {
Expand All @@ -46,9 +46,7 @@ module.exports = function posthtmlrc (ctx, path, options) {
.load(path)
.then((result) => {
if (!result) {
console.log(
'PostHTML Config could not be loaded. Please check your PostHTML Config.'
)
throw new Error('PostHTML Config could not be loaded. Please check your PostHTML Config.');
}

return result ? result.config : {}
Expand Down
18 changes: 5 additions & 13 deletions lib/plugins.js
Expand Up @@ -35,19 +35,11 @@ module.exports = function plugins (config) {
} else {
config = config.plugins

const load = (plugin, options) => {
if (options === null || Object.keys(options).length === 0) {
try {
return require(plugin)
} catch (err) {
console.log(err)
}
} else {
try {
return require(plugin)(options)
} catch (err) {
console.log(err)
}
const load = (plugin, options = {}) => {
try {
return require(plugin)(options)
} catch (err) {
console.log(err)
}
}

Expand Down
26 changes: 13 additions & 13 deletions package.json
@@ -1,37 +1,37 @@
{
"name": "posthtml-load-config",
"version": "1.0.0",
"version": "2.0.0",
"description": "Autoload Config for PostHTML",
"engines": {
"node": ">=4",
"npm": ">=3"
"node": ">=10"
},
"main": "index.js",
"scripts": {
"version": "npm run logs && git add CHANGELOG.md && git commit -m \"build: update changelog\"",
"lint": "standard",
"test": "nyc ava test/js/index.js test/rc/index.js test/pkg/index.js",
"logs": "standard-changelog > CHANGELOG.md",
"docs": "jsdoc2md index.js > INDEX.md",
"clean": "rm -rf .nyc_output coverage jsdoc-api dmd",
"start": "sudo npm run clean && npm run lint && sudo npm test"
"start": "npm run clean && npm run lint && npm test"
},
"dependencies": {
"cosmiconfig": "^2.1.0",
"posthtml-load-options": "^1.0.0"
},
"devDependencies": {
"ava": "^0.16.0",
"coveralls": "^2.11.15",
"htmlnano": "^0.1.5",
"jsdoc-to-markdown": "^2.0.0",
"nyc": "^8.4.0",
"posthtml": "^0.9.1",
"posthtml-content": "0.0.2",
"ava": "^3.12.1",
"coveralls": "^3.1.0",
"htmlnano": "^0.2.6",
"jsdoc-to-markdown": "^6.0.1",
"nyc": "^15.1.0",
"posthtml": "^0.13.3",
"posthtml-content": "0.0.3",
"posthtml-include": "^1.1.0",
"posthtml-pug": "^1.0.2",
"posthtml-sugarml": "^1.0.0-alpha3",
"standard": "^8.4.0",
"standard-changelog": "0.0.1"
"standard": "^14.3.4",
"standard-changelog": "^2.0.24"
},
"ava": {
"verbose": "true"
Expand Down
16 changes: 12 additions & 4 deletions test/js/index.js
Expand Up @@ -33,7 +33,9 @@ function posthtml (config, fix, log) {
const posthtmlrc = require('../..')

test('posthtml.config.js - {Object} - Parser SML', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

const parser = require('posthtml-sugarml')()

Expand All @@ -45,7 +47,9 @@ test('posthtml.config.js - {Object} - Parser SML', (t) => {
})

test('posthtml.config.js - {Function} - Process SML', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

return posthtmlrc(ctx).then((config) => {
posthtml(config, 'index.sml', true)
Expand All @@ -65,7 +69,9 @@ test.skip('posthtml.config.js - {Function} - Process HTML', (t) => {
})

test('posthtml.config.js - {Function} - Render JS', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

return posthtmlrc(ctx).then((config) => {
t.is(config.options.render, undefined)
Expand All @@ -75,7 +81,9 @@ test('posthtml.config.js - {Function} - Render JS', (t) => {
})

test('posthtml.config.js - {Function} - Render JSX', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

return posthtmlrc(ctx).then((config) => {
t.is(config.options.render, undefined)
Expand Down
4 changes: 2 additions & 2 deletions test/js/posthtml.config.js
Expand Up @@ -4,9 +4,9 @@ module.exports = (ctx) => {
from: './fixtures/index.sml',
to: './expect/index.html',
plugins: {
'posthtml-include': false,
'posthtml-include': {},
'posthtml-content': false,
'htmlnano': ctx.env === 'production' ? {} : false
htmlnano: ctx.env === 'production' ? {} : false
}
}
}
16 changes: 12 additions & 4 deletions test/pkg/index.js
Expand Up @@ -33,7 +33,9 @@ function posthtml (config, fix, log) {
const posthtmlrc = require('../..')

test('package.json - {Object} - Parser SML', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

const parser = require('posthtml-sugarml')()

Expand All @@ -45,7 +47,9 @@ test('package.json - {Object} - Parser SML', (t) => {
})

test('package.json - {Object} - Process SML', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

return posthtmlrc(ctx).then((config) => {
posthtml(config, 'index.sml', true)
Expand All @@ -65,7 +69,9 @@ test.skip('packagee.json - {Object} - Process HTML', (t) => {
})

test('package.json - {Object} - Render JS', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

return posthtmlrc(ctx).then((config) => {
t.is(config.options.render, undefined)
Expand All @@ -75,7 +81,9 @@ test('package.json - {Object} - Render JS', (t) => {
})

test('package.json - {Object} - Render JSX', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

return posthtmlrc(ctx).then((config) => {
t.is(config.options.render, undefined)
Expand Down
16 changes: 12 additions & 4 deletions test/rc/index.js
Expand Up @@ -33,7 +33,9 @@ function posthtml (config, fix, log) {
const posthtmlrc = require('../..')

test('.posthtmlrc - {Object} - Parser SML', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

const parser = require('posthtml-sugarml')()

Expand All @@ -45,7 +47,9 @@ test('.posthtmlrc - {Object} - Parser SML', (t) => {
})

test('.posthtmlrc - {Object} - Process SML', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

return posthtmlrc(ctx).then((config) => {
posthtml(config, 'index.sml', true)
Expand All @@ -65,7 +69,9 @@ test.skip('.posthtmlrc - {Object} - Process HTML', (t) => {
})

test('.posthtmlrc - {Object} - Render JS', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

return posthtmlrc(ctx).then((config) => {
t.is(config.options.render, undefined)
Expand All @@ -75,7 +81,9 @@ test('.posthtmlrc - {Object} - Render JS', (t) => {
})

test('.posthtmlrc - {Object} - Render JSX', (t) => {
const ctx = {}
const ctx = {
cwd: __dirname
}

return posthtmlrc(ctx).then((config) => {
t.is(config.options.render, undefined)
Expand Down

0 comments on commit 0e5bf3e

Please sign in to comment.