Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- v6
- v5
- v4
after_success:
Expand Down
22 changes: 17 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
## [0.1.2] - 28-04-2016
### Added
- Added #68, node 6 to config travis

### Change
- Update #67, readme
- Update test, add await when create tmpFolder
- Update #65, update devDep

### Fixed
- Fixed bug witch replace options. !path.extname(undefined) === true O_o

## [0.1.1] - 22-04-2016
## Added
### Added
- Added #64, updtr
- Added #62, ava-codemods
- Added #59, tempfile for test
Expand All @@ -14,19 +26,19 @@
- Remove #59, del not need

## [0.1.0] - 23-03-2016
## Added
### Added
- Added #16, replace file(s)
- Added #9, read filed in folder and transform to folder

## [0.0.22] - 23-03-2016
## Added
### Added
- Added test with indent
- Added node support in package.json

## Fixed
### Fixed
- Fixed #53, coverage for windows

## Removed
### Removed
- Remove #56, support node 0.12

## [0.0.21] - 21-03-2016
Expand Down
140 changes: 101 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![NPM version][npm-image]][npm-url][![Trasiv Build Status][travis-image]][travis-url][![AppVeyor Build Status][appveyor-img]][appveyor][![Coveralls Status][coveralls-image]][coveralls-url][![Dependency Status][depstat-image]][depstat-url][![DevDependency Status][depstat-dev-image]][depstat-dev-url][![XO code style][codestyle-image]][codestyle-url]

> CLI for [PostHTML][posthtml-url]
> Simple CLI for [PostHTML][posthtml-url]

## Install

Expand All @@ -15,52 +15,114 @@ npm install --global posthtml-cli
```console
$ posthtml --help

Usage
posthtml --output|-o output.html --input|-i input.html [--config|-c path/to/json/config]

Options
--config, -c Path to JSON file [string]
--output, -o Output html file/folder result [required]
--input, -i Input html file/folder [required]
--replace, -r Replace input file(s) [boolean]
--help, -h Show help [boolean]
--version, -v Show version number [boolean]

Example sample
posthtml -o output.html -i input.html

Example options config
posthtml -o output.html -i input.html -c posthtml.json
or
posthtml -o output.html -i input.html -c posthtml.js

Example read dir
posthtml -o outputFolder/ -i inputFolder/*.html
or
posthtml -o outputFolder/ -i inputFolder/**/*.html
Usage
posthtml --output|-o output.html --input|-i input.html [--config|-c path/to/json/config]

Options
--config, -c Path to JSON file [string]
--output, -o Output html file/folder result [required]
--input, -i Input html file/folder [required]
--replace, -r Replace input file(s) [boolean]
--help, -h Show help [boolean]
--version, -v Show version number [boolean]
```

For reading config used [posthtml-load-plugins](https://github.com/michael-ciniawsky/posthtml-load-plugins)
## Config
*Default read options for plugins from package.json usin [posthtml-load-plugins](https://github.com/michael-ciniawsky/posthtml-load-plugins)*

### ```package.json```

*Default read options for plugins from package.json*
```json
{
"name": "my project",
"devDependencies": {
"posthtml-custom-elements": "^1.0.3",
"posthtml-style-to-file": "^0.1.1"
},
"posthtml": {
"customElements": {
"defaultTag": "span"
},
"styleToFile": {
"path": "./dist/style.css"
}
}
"name": "my project",
"dependencies": {
"posthtml-bem": "^0.2.2",
"posthtml-each": "^1.0.1",
"posthtml-include": "^1.0.2"
},
"devDependencies": {
"posthtml-style-to-file": "^0.1.1"
},
"posthtml": {
"bem": {
"elemPrefix": "__",
"modPrefix": "-",
"modDlmtr": "--"
},
"include": {
"root": "./",
"encoding": "utf-8"
},
"styleToFile": {
"path": "./dist/style.css"
}
}
}
```

### ```[name].[ext]```

#### JS
```js
module.exports = {
bem: {
elemPrefix: '__',
modPrefix: '-',
modDlmtr: '--'
},
include: {
root: './',
encoding: 'utf-8'
},
styleToFile: {
path: './dist/style.css'
}
}
```
#### ```JSON```

```json
{
"bem": {
"elemPrefix": "__",
"modPrefix": "-",
"modDlmtr": "--"
},
"include": {
"root": "./",
"encoding": "utf-8"
},
"styleToFile": {
"path": "./dist/style.css"
}
}
```

## Examples

### Example sample
```console
$ posthtml -o output.html -i input.html
```

### Example options config
```console
$ posthtml -o output.html -i input.html -c posthtml.json
```

```console
$ posthtml -o output.html -i input.html -c posthtml.js
```

### Example read dir
```console
$ posthtml -o outputFolder/ -i inputFolder/*.html
```

```console
$ posthtml -o outputFolder/ -i inputFolder/**/*.html
```

## License
MIT

Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "5"
- nodejs_version: "4"

Expand Down
4 changes: 3 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ function processing(file, output) {
}

function isFile(outputPath) {
if (outputPath === undefined) {
return false;
}
return Boolean(path.extname(outputPath));
}

Expand All @@ -70,7 +73,6 @@ globby(argv.input).then(function (files) {
if (argv.output !== undefined) {
createFolder(argv.output);
}

files.forEach(function (file) {
var output = isFile(argv.output) ? argv.output : getOutput(file);
processing(file, output);
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "posthtml-cli",
"version": "0.1.1",
"version": "0.1.2",
"description": "CLI for posthtml",
"bin": {
"posthtml": "./cli.js"
Expand All @@ -11,7 +11,7 @@
"scripts": {
"test": "xo && nyc ava",
"prepush": "xo",
"update": "updtr && ava-codemods"
"update": "updtr && ava-codemods --force"
},
"repository": {
"type": "git",
Expand All @@ -30,17 +30,17 @@
"homepage": "https://github.com/GitScrum/posthtml-cli#readme",
"dependencies": {
"globby": "^4.0.0",
"posthtml": "^0.8.3",
"posthtml": "^0.8.6",
"posthtml-load-plugins": "^0.9.5",
"yargs": "^4.6.0"
},
"devDependencies": {
"ava": "^0.14.0",
"ava-codemods": "^0.2.1",
"coveralls": "^2.11.8",
"coveralls": "^2.11.9",
"cpy": "^4.0.0",
"execa": "^0.2.2",
"nyc": "^6.4.0",
"execa": "^0.4.0",
"nyc": "^6.4.1",
"path-exists": "^2.1.0",
"posthtml-custom-elements": "^1.0.3",
"read-pkg": "^1.1.0",
Expand Down
4 changes: 2 additions & 2 deletions test/test-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ test('Transform html witch config in file', async t => {

test('Transform html from folder', async t => {
t.plan(2);
const folder = tempfile();
const folder = await tempfile();
await execa('../cli.js', ['-i', 'fixtures/*.html', '-o', `${folder}/`]);
t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`)));
t.is((await read('expected/output-indent.html')), (await read(`${folder}/input-indent.html`)));
});

test('Transform html witch options replace', async t => {
t.plan(2);
const folder = tempfile();
const folder = await tempfile();
await copy(['fixtures/*.html'], `${folder}/`);
await execa('../cli.js', ['-i', `${folder}/*.html`, '-r']);
t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`)));
Expand Down