Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit 40d3028

Browse files
authored
Merge pull request #5 from asset-pipe/develop
Update repo and add semantic-release
2 parents 115eea3 + 86dd1c6 commit 40d3028

File tree

11 files changed

+1915
-317
lines changed

11 files changed

+1915
-317
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 4
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
13+
[{*.json,.stylelintrc,.eslintrc,.babelrc}]
14+
indent_size = 2

.eslintrc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
2-
"root": true,
3-
"parserOptions": {
4-
"ecmaVersion": 2017
5-
},
6-
"extends": ["finn", "finn/node"],
7-
"env": {
8-
"node": true,
9-
"jest": true
10-
}
11-
}
2+
"root": true,
3+
"parserOptions": {
4+
"ecmaVersion": 2017
5+
},
6+
"extends": [
7+
"finn",
8+
"finn/node",
9+
"finn-prettier"
10+
],
11+
"env": {
12+
"node": true,
13+
"jest": true
14+
}
15+
}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ tmp/**/*
66
.idea/**/*
77
*.iml
88
*.log
9-
coverage
9+
coverage
10+
.vscode

.travis.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
language: node_js
2-
32
node_js:
4-
- "8"
5-
3+
- '8'
64
script:
75
- npm test
86
- npm run lint
7+
cache:
8+
npm: true
9+
directories:
10+
- node_modules
11+
after_success:
12+
- npm run semantic-release
13+
branches:
14+
except:
15+
- /^v\d+\.\d+\.\d+$/

LICENSE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- LICENSEFILE/ -->
2+
3+
<h1>License</h1>
4+
5+
Unless stated otherwise all works are:
6+
7+
<ul><li>Copyright &copy; Richard Walker</li></ul>
8+
9+
and licensed under:
10+
11+
<ul><li><a href="http://spdx.org/licenses/MIT.html">MIT License</a></li></ul>
12+
13+
<h2>MIT License</h2>
14+
15+
<pre>
16+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
17+
18+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
</pre>
22+
23+
<!-- /LICENSEFILE -->

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
# asset-pipe-css-writer
1+
<!-- TITLE/ -->
2+
3+
<h1>asset-pipe-css-writer</h1>
4+
5+
<!-- /TITLE -->
6+
7+
8+
<!-- BADGES/ -->
9+
10+
<span class="badge-travisci"><a href="http://travis-ci.org/asset-pipe/asset-pipe-css-writer" title="Check this project's build status on TravisCI"><img src="https://img.shields.io/travis/asset-pipe/asset-pipe-css-writer/master.svg" alt="Travis CI Build Status" /></a></span>
11+
<span class="badge-npmversion"><a href="https://npmjs.org/package/asset-pipe-css-writer" title="View this project on NPM"><img src="https://img.shields.io/npm/v/asset-pipe-css-writer.svg" alt="NPM version" /></a></span>
12+
<span class="badge-daviddm"><a href="https://david-dm.org/asset-pipe/asset-pipe-css-writer" title="View the status of this project's dependencies on DavidDM"><img src="https://img.shields.io/david/asset-pipe/asset-pipe-css-writer.svg" alt="Dependency Status" /></a></span>
13+
<span class="badge-daviddmdev"><a href="https://david-dm.org/asset-pipe/asset-pipe-css-writer#info=devDependencies" title="View the status of this project's development dependencies on DavidDM"><img src="https://img.shields.io/david/dev/asset-pipe/asset-pipe-css-writer.svg" alt="Dev Dependency Status" /></a></span>
14+
15+
<!-- /BADGES -->
16+
217

318
[![Greenkeeper badge](https://badges.greenkeeper.io/asset-pipe/asset-pipe-css-writer.svg)](https://greenkeeper.io/)
419

@@ -79,4 +94,4 @@ const consumer = new Writeable({
7994
})
8095

8196
writer.pipe(consumer)
82-
```
97+
```

lib/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const readPkgUp = require('read-pkg-up');
88
const postcss = require('postcss');
99
const atImport = require('postcss-import');
1010

11-
module.exports.identifyCssModule = async function identifyCssModule (filePath) {
11+
module.exports.identifyCssModule = async function identifyCssModule(filePath) {
1212
const { pkg: { name, version }, path: packagePath } = await readPkgUp({
1313
normalize: false,
1414
cwd: path.dirname(filePath),
@@ -18,7 +18,7 @@ module.exports.identifyCssModule = async function identifyCssModule (filePath) {
1818
return { name, version, file };
1919
};
2020

21-
module.exports.bundleCssModule = async function bundleCssModule (filePath) {
21+
module.exports.bundleCssModule = async function bundleCssModule(filePath) {
2222
const fileContents = await readFile(filePath, 'utf8');
2323
const { css } = await postcss()
2424
.use(atImport())

lib/writer.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const assert = require('assert');
88
const { hasher } = require('asset-pipe-common');
99

1010
module.exports = class Writer extends Readable {
11-
constructor (files = []) {
11+
constructor(files = []) {
1212
super({ objectMode: true });
1313

1414
assert(
@@ -17,22 +17,36 @@ module.exports = class Writer extends Readable {
1717
);
1818
this.files = Array.isArray(files) ? files : [files];
1919
for (const file of this.files) {
20-
assert(typeof file === 'string', `Expected 'file' (${file}) to be of type 'string', instead got '${typeof file}'`);
21-
assert(isAbsolute(file), `Expected 'file' (${file}) to be an absolute path to a file but it was not`);
22-
assert(existsSync(file), `Expected 'file' (${file}) to exist on file system but it did not`);
20+
assert(
21+
typeof file === 'string',
22+
`Expected 'file' (${file}) to be of type 'string', instead got '${typeof file}'`
23+
);
24+
assert(
25+
isAbsolute(file),
26+
`Expected 'file' (${file}) to be an absolute path to a file but it was not`
27+
);
28+
assert(
29+
existsSync(file),
30+
`Expected 'file' (${file}) to exist on file system but it did not`
31+
);
2332
}
2433
}
2534

26-
async _read () {
35+
async _read() {
2736
const file = this.files.shift();
2837
if (!file) {
2938
this.push(null);
3039
return;
3140
}
3241

3342
try {
34-
const [css, meta] = await Promise.all([bundleCssModule(file), identifyCssModule(file)]);
35-
meta.id = hasher(`${meta.name}|${meta.version}|${meta.file}|${css}`);
43+
const [css, meta] = await Promise.all([
44+
bundleCssModule(file),
45+
identifyCssModule(file),
46+
]);
47+
meta.id = hasher(
48+
`${meta.name}|${meta.version}|${meta.file}|${css}`
49+
);
3650
meta.content = css;
3751
this.push(meta);
3852
} catch (err) {

0 commit comments

Comments
 (0)