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

Commit 6b5c934

Browse files
committed
chore(style): upgrade prettier and format the readme with it
1 parent ddc9347 commit 6b5c934

File tree

4 files changed

+42
-23
lines changed

4 files changed

+42
-23
lines changed

README.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717

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

20-
A module that takes any number of css file entry points and packages them together with meta data before providing them as a readable stream.
20+
A module that takes any number of css file entry points and packages them
21+
together with meta data before providing them as a readable stream.
2122

2223
## Overview
2324

2425
Given any number of css file paths, for each file path, this module will:
26+
2527
1. fetch the file at the path
2628
2. fetch a name and version from the nearest package.json to the file
27-
3. bundle the css found in the file (resolving any @import statements and inlining them)
29+
3. bundle the css found in the file (resolving any @import statements and
30+
inlining them)
2831
4. put all this together in an object (See Output data format below)
2932

3033
The module provides a readable stream of the resulting objects.
@@ -55,43 +58,53 @@ npm install asset-pipe-css-writer
5558
## Usage
5659

5760
### Require the writer
61+
5862
```js
59-
const CssWriter = require('asset-pipe-css-writer')
63+
const CssWriter = require('asset-pipe-css-writer');
6064
```
6165

6266
### Instantiating the writer
6367

6468
Either pass a path to a single css file:
69+
6570
```js
66-
const writer = new CssWriter('/path/to/css/file.css')
71+
const writer = new CssWriter('/path/to/css/file.css');
6772
```
6873

6974
Or pass an array of paths to css files:
75+
7076
```js
71-
const writer = new CssWriter(['/path/to/css/file1.css', '/path/to/css/file2.css'])
77+
const writer = new CssWriter([
78+
'/path/to/css/file1.css',
79+
'/path/to/css/file2.css',
80+
]);
7281
```
7382

7483
### Consuming content from the writer
7584

76-
The writer is a readable stream in object mode so in order to access the data you may register a data handler
77-
and listen for objects to be passed to the handler:
85+
The writer is a readable stream in object mode so in order to access the data
86+
you may register a data handler and listen for objects to be passed to the
87+
handler:
88+
7889
```js
7990
writer.on('data', data => {
8091
// { id, name, version, file, content }
81-
})
92+
});
8293
```
8394

84-
You might also pipe the writer into a writeable or transform stream (with input in object mode):
95+
You might also pipe the writer into a writeable or transform stream (with input
96+
in object mode):
97+
8598
```js
86-
const { Writable } = require('stream')
99+
const { Writable } = require('stream');
87100
const consumer = new Writeable({
88101
objectMode: true,
89102
write(chunk, encoding, callback) {
90103
// chunk will be an object of the shape: { id, name, version, file, content }
91-
console.log(chunk)
92-
callback()
93-
}
94-
})
104+
console.log(chunk);
105+
callback();
106+
},
107+
});
95108

96-
writer.pipe(consumer)
109+
writer.pipe(consumer);
97110
```

lib/writer.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@ module.exports = class Writer extends Readable {
1919
for (const file of this.files) {
2020
assert(
2121
typeof file === 'string',
22-
`Expected 'file' (${file}) to be of type 'string', instead got '${typeof file}'`
22+
`Expected 'file' (${
23+
file
24+
}) to be of type 'string', instead got '${typeof file}'`
2325
);
2426
assert(
2527
isAbsolute(file),
26-
`Expected 'file' (${file}) to be an absolute path to a file but it was not`
28+
`Expected 'file' (${
29+
file
30+
}) to be an absolute path to a file but it was not`
2731
);
2832
assert(
2933
existsSync(file),
30-
`Expected 'file' (${file}) to exist on file system but it did not`
34+
`Expected 'file' (${
35+
file
36+
}) to exist on file system but it did not`
3137
);
3238
}
3339
}

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
"husky": "^0.14.3",
4040
"jest": "^21.2.1",
4141
"lint-staged": "^5.0.0",
42-
"prettier": "^1.7.4",
42+
"prettier": "^1.8.2",
4343
"projectz": "^1.4.0",
4444
"semantic-release": "^8.2.0"
4545
},
4646
"scripts": {
47-
"format": "prettier --write --single-quote --trailing-comma=all --tab-width=4 lib/**/*.js test/**/*.js",
47+
"format": "prettier --write --single-quote --trailing-comma=all --tab-width=4 lib/**/*.js test/**/*.js README.md",
4848
"lint": "eslint .",
4949
"test": "jest --coverage",
5050
"lint:format": "eslint --fix .",

0 commit comments

Comments
 (0)