Skip to content

Commit 747c2cd

Browse files
author
Ivan Demidov
committed
style(*): reformatting for standard
1 parent 950046a commit 747c2cd

File tree

4 files changed

+168
-171
lines changed

4 files changed

+168
-171
lines changed

.editorconfig

-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,5 @@ insert_final_newline = true
1111
[{package.json,*.yml,*.jade,*.pss,*.css}]
1212
indent_size = 2
1313

14-
[{*.js,*.jsx}]
15-
indent_style = tab
16-
1714
[*.md]
1815
trim_trailing_whitespace = false

cli.js

+70-70
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,91 @@
11
#!/usr/bin/env node
22

3-
var path = require('path');
4-
var fs = require('fs');
5-
var posthtml = require('posthtml');
6-
var globby = require('globby');
7-
var pathExists = require('path-exists');
3+
var path = require('path')
4+
var fs = require('fs')
5+
var posthtml = require('posthtml')
6+
var globby = require('globby')
7+
var pathExists = require('path-exists')
88
var argv = require('yargs')
9-
.usage('Usage: $0 [-o output-file/directory|-r] [-i input-file/directory] [--config|-c path/to/file/config]')
10-
.example('posthtml -o output.html -i input.html', 'Default example')
11-
.alias('i', 'input')
12-
.array('input')
13-
.demand(['i'])
14-
.alias('o', 'output')
15-
.alias('r', 'replace')
16-
.alias('u', 'use')
17-
.array('use')
18-
.pkgConf('posthtml')
19-
.config('c')
20-
.alias('c', 'config')
21-
.version(function () {
22-
return require('./package.json').version;
23-
})
24-
.alias('v', 'version')
25-
.help('h')
26-
.alias('h', 'help')
27-
.check(function (argv) {
28-
if (argv.output && argv.replace) {
29-
throw new Error('Both `output file` and `replace` provided: please use either --output or --replace option.');
30-
}
31-
if (!argv.output && !argv.replace) {
32-
throw new Error('Both `output file` and `replace` missing: please use either --output or --replace option.');
33-
}
34-
return true;
35-
})
36-
.argv;
9+
.usage('Usage: $0 [-o output-file/directory|-r] [-i input-file/directory] [--config|-c path/to/file/config]')
10+
.example('posthtml -o output.html -i input.html', 'Default example')
11+
.alias('i', 'input')
12+
.array('input')
13+
.demand(['i'])
14+
.alias('o', 'output')
15+
.alias('r', 'replace')
16+
.alias('u', 'use')
17+
.array('use')
18+
.pkgConf('posthtml')
19+
.config('c')
20+
.alias('c', 'config')
21+
.version(function () {
22+
return require('./package.json').version
23+
})
24+
.alias('v', 'version')
25+
.help('h')
26+
.alias('h', 'help')
27+
.check(function (argv) {
28+
if (argv.output && argv.replace) {
29+
throw new Error('Both `output file` and `replace` provided: please use either --output or --replace option.')
30+
}
31+
if (!argv.output && !argv.replace) {
32+
throw new Error('Both `output file` and `replace` missing: please use either --output or --replace option.')
33+
}
34+
return true
35+
})
36+
.argv
3737

3838
function processing(file, output) {
39-
// get htmls
40-
var html = fs.readFileSync(file, 'utf8');
41-
var ext = {};
39+
// get htmls
40+
var html = fs.readFileSync(file, 'utf8')
41+
var ext = {}
4242

43-
// create config extends for posthtml-load-plugins
44-
if (argv.use) {
45-
argv.use.forEach(function (plugin) {
46-
ext[plugin] = argv[plugin] || {};
47-
});
48-
}
43+
// create config extends for posthtml-load-plugins
44+
if (argv.use) {
45+
argv.use.forEach(function (plugin) {
46+
ext[plugin] = argv[plugin] || {}
47+
})
48+
}
4949

50-
// processing
51-
posthtml(require('posthtml-load-plugins')(argv.config, ext))
52-
.process(html)
53-
.then(function (result) {
54-
fs.writeFileSync(output, result.html);
55-
});
50+
// processing
51+
posthtml(require('posthtml-load-plugins')(argv.config, ext))
52+
.process(html)
53+
.then(function (result) {
54+
fs.writeFileSync(output, result.html)
55+
})
5656
}
5757

5858
function isFile(outputPath) {
59-
if (outputPath === undefined) {
60-
return false;
61-
}
62-
return Boolean(path.extname(outputPath));
59+
if (outputPath === undefined) {
60+
return false
61+
}
62+
return Boolean(path.extname(outputPath))
6363
}
6464

6565
function getOutput(file) {
66-
if (argv.output === undefined) {
67-
return file;
68-
}
69-
return argv.output + path.basename(file);
66+
if (argv.output === undefined) {
67+
return file
68+
}
69+
return argv.output + path.basename(file)
7070
}
7171

7272
function createFolder(outputPath) {
73-
if (isFile(outputPath) === true) {
74-
outputPath = path.dirname(outputPath);
75-
}
73+
if (isFile(outputPath) === true) {
74+
outputPath = path.dirname(outputPath)
75+
}
7676

77-
if (pathExists.sync(outputPath) === false) {
78-
fs.mkdirSync(outputPath);
79-
}
77+
if (pathExists.sync(outputPath) === false) {
78+
fs.mkdirSync(outputPath)
79+
}
8080
}
8181

8282
globby(argv.input).then(function (files) {
83-
if (argv.output !== undefined) {
84-
createFolder(argv.output);
85-
}
83+
if (argv.output !== undefined) {
84+
createFolder(argv.output)
85+
}
8686

87-
files.forEach(function (file) {
88-
var output = isFile(argv.output) ? argv.output : getOutput(file);
89-
processing(file, output);
90-
});
91-
});
87+
files.forEach(function (file) {
88+
var output = isFile(argv.output) ? argv.output : getOutput(file)
89+
processing(file, output)
90+
})
91+
})

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = {
7878
styleToFile: {
7979
path: './dist/style.css'
8080
}
81-
};
81+
}
8282
```
8383

8484
#### ```JSON```

0 commit comments

Comments
 (0)