Skip to content

Commit 8dc0b4d

Browse files
committed
refactor: Updated tests from callback hell to async/await
1 parent 42b15d7 commit 8dc0b4d

File tree

7 files changed

+143
-130
lines changed

7 files changed

+143
-130
lines changed

.releaserc.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ module.exports = {
33
'@semantic-release/commit-analyzer',
44
'@semantic-release/release-notes-generator',
55
'@semantic-release/changelog',
6-
['@semantic-release/npm', {}],
6+
[
7+
'@semantic-release/npm',
8+
{
9+
pkgRoot: 'dist',
10+
},
11+
],
712
'@semantic-release/github',
813
'@semantic-release/git',
914
],

README.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ body {
1616
font-family: 'Tangerine';
1717
font-style: normal;
1818
font-weight: 400;
19-
src: local('Tangerine'),
20-
url(https://fonts.gstatic.com/s/tangerine/v7/HGfsyCL5WASpHOFnouG-RKCWcynf_cDxXwCLxiixG1c.ttf)
21-
format('truetype');
19+
src: url(https://fonts.gstatic.com/s/tangerine/v12/IurY6Y5j_oScZZow4VOxCZZM.woff2) format('woff2');
2220
}
2321
body {
2422
font-size: 13px;
@@ -28,8 +26,8 @@ body {
2826
## Usage
2927

3028
```js
31-
var importUrl = require('postcss-import-url');
32-
var options = {};
29+
const importUrl = require('postcss-import-url');
30+
const options = {};
3331
postcss([importUrl(options)]).process(css, {
3432
// Define a `from` option to resolve relative @imports in the initial css to a url.
3533
from: 'https://example.com/styles.css',
@@ -42,7 +40,7 @@ See [PostCSS](https://github.com/postcss/postcss#usage) docs for examples for yo
4240

4341
- `recursive` (boolean) To import URLs recursively (default: `true`)
4442
- `resolveUrls` (boolean) To transform relative URLs found in remote stylesheets into fully qualified URLs ([see #18](https://github.com/unlight/postcss-import-url/pull/18)) (default: `false`)
45-
- `modernBrowser` (boolean) Set user-agent string to 'Mozilla/5.0 AppleWebKit/537.36 Chrome/65.0.0.0 Safari/537.36', this option maybe useful for importing fonts from Google. Google check `user-agent` header string and respond can be different (default: `false`)
43+
- `modernBrowser` (boolean) Set user-agent string to 'Mozilla/5.0 AppleWebKit/537.36 Chrome/80.0.0.0 Safari/537.36', this option maybe useful for importing fonts from Google. Google check `user-agent` header string and respond can be different (default: `false`)
4644
- `userAgent` (string) Custom user-agent header (default: `null`)
4745

4846
## Known Issues

Taskfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
PATH="$PWD/node_modules/.bin":$PATH
3+
set -e
4+
5+
build_cp() {
6+
set -x
7+
rm -rfv dist
8+
mkdir dist
9+
cp -rfv index.js dist
10+
cp -fv README.md LICENSE package.json dist
11+
set +x
12+
}
13+
14+
"$@"

gulpfile.js

+9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ gulp.task('test', function () {
1919
.on('end', connect.serverClose);
2020
});
2121

22+
gulp.task('test:w', function () {
23+
var startServer = gulp.task('start-server');
24+
startServer();
25+
return gulp
26+
.src('test/*.js', { read: false })
27+
.pipe(mocha({ timeout: 5000, watch: true }))
28+
.on('end', connect.serverClose);
29+
});
30+
2231
gulp.task('default', gulp.series(['lint', 'test']));
2332

2433
gulp.task('watch', function () {

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function createPromise(remoteFile, options) {
8686
reqOptions.headers['connection'] = 'keep-alive';
8787
if (options.modernBrowser) {
8888
reqOptions.headers['user-agent'] =
89-
'Mozilla/5.0 AppleWebKit/538.0 Chrome/65.0.0.0 Safari/538';
89+
'Mozilla/5.0 AppleWebKit/538.0 Chrome/80.0.0.0 Safari/538';
9090
}
9191
if (options.userAgent) {
9292
reqOptions.headers['user-agent'] = String(options.userAgent);

package.json

+12-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "postcss-import-url",
33
"version": "5.1.0",
44
"description": "PostCSS plugin inlines remote files.",
5+
"main": "index.js",
56
"keywords": [
67
"postcss",
78
"css",
@@ -12,6 +13,13 @@
1213
"engines": {
1314
"node": ">=10"
1415
},
16+
"scripts": {
17+
"build": "sh Taskfile build_cp",
18+
"eslint": "node node_modules/eslint/bin/eslint index.js",
19+
"eslint:fix": "npm run eslint -- --fix",
20+
"test": "gulp",
21+
"test:w": "gulp test:w"
22+
},
1523
"dependencies": {
1624
"http-https": "^1.0.0",
1725
"is-url": "^1.2.4",
@@ -25,24 +33,18 @@
2533
"devDependencies": {
2634
"@semantic-release/changelog": "^5.0.1",
2735
"@semantic-release/git": "^9.0.0",
28-
"chai": "^4.2.0",
36+
"expect": "^26.6.2",
2937
"gulp": "^4.0.2",
3038
"gulp-connect": "^5.7.0",
3139
"gulp-eslint": "^6.0.0",
3240
"gulp-mocha": "^7.0.2",
33-
"husky": "^4.2.3",
41+
"husky": "^4.3.5",
3442
"postcss": "^8.2.0",
3543
"precise-commits": "^1.0.2",
36-
"prettier": "^2.0.2",
37-
"semantic-release": "^17.0.4",
44+
"prettier": "^2.2.1",
45+
"semantic-release": "^17.3.0",
3846
"tcp-ping": "^0.1.1"
3947
},
40-
"scripts": {
41-
"eslint": "node node_modules/eslint/bin/eslint index.js",
42-
"eslint:fix": "npm run eslint -- --fix",
43-
"test": "gulp"
44-
},
45-
"main": "index.js",
4648
"directories": {
4749
"test": "test"
4850
},

0 commit comments

Comments
 (0)