Skip to content

Commit 1a212f4

Browse files
committed
fix ci + add notice
1 parent 5e633fa commit 1a212f4

8 files changed

Lines changed: 188 additions & 84 deletions

File tree

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ubuntu-latest, windows-latest]
12+
node-version: [lts/*, latest]
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Use Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
- run: npm ci
20+
- run: npm test

.travis.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

Readme.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
# css [![Build Status](https://travis-ci.org/reworkcss/css.svg?branch=master)](https://travis-ci.org/reworkcss/css)
1+
# css
2+
3+
[![npm package version](https://img.shields.io/npm/v/css) ![npm downloads](https://img.shields.io/npm/dm/css)](https://www.npmjs.com/package/css)
4+
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/reworkcss/css/test.yml)](https://github.com/reworkcss/css/actions)
5+
[![License](https://img.shields.io/github/license/reworkcss/css)](https://github.com/reworkcss/css)
6+
7+
> [!NOTE]
8+
> There have not been material changes to this package in 10 years. New changes and bug fixes are not planned. In the event of concrete security issues, changes may still occur. We recommend moving to something else more modern.
9+
10+
> [!TIP]
11+
> Use [@adobe/css-tools](https://github.com/adobe/css-tools) instead
212
313
CSS parser / stringifier.
414

package-lock.json

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

package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,8 @@
1313
"source-map": "^0.6.1",
1414
"source-map-resolve": "^0.6.0"
1515
},
16-
"devDependencies": {
17-
"mocha": "^8.0.1",
18-
"should": "^13.2.3",
19-
"matcha": "^0.7.0",
20-
"bytes": "^3.1.0"
21-
},
2216
"scripts": {
23-
"benchmark": "matcha",
24-
"test": "mocha --require should --reporter spec test/*.js"
17+
"test": "node --test"
2518
},
2619
"author": "TJ Holowaychuk <tj@vision-media.ca>",
2720
"license": "MIT",

test/cases.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var fs = require('fs');
22
var path = require('path');
3+
var assert = require('node:assert');
4+
var { describe, it } = require('node:test');
35
var parse = require('../').parse;
46
var stringify = require('../').stringify;
57

@@ -14,17 +16,17 @@ cases.forEach(function(name) {
1416

1517
it('should match ast.json', function() {
1618
var ast = parseInput();
17-
ast.should.containDeep(JSON.parse(readFile(astFile)));
19+
containDeep(ast, JSON.parse(readFile(astFile)));
1820
});
1921

2022
it('should match output.css', function() {
2123
var output = stringify(parseInput());
22-
output.should.equal(readFile(outputFile).trim());
24+
assert.strictEqual(output, readFile(outputFile).trim());
2325
});
2426

2527
it('should match compressed.css', function() {
2628
var compressed = stringify(parseInput(), { compress: true });
27-
compressed.should.equal(readFile(compressedFile));
29+
assert.strictEqual(compressed, readFile(compressedFile));
2830
});
2931

3032
function parseInput() {
@@ -42,3 +44,20 @@ function readFile(file) {
4244

4345
return src;
4446
}
47+
48+
// Assert that `actual` deeply contains every property/element of `expected`.
49+
function containDeep(actual, expected) {
50+
if (Array.isArray(expected)) {
51+
assert.ok(Array.isArray(actual));
52+
expected.forEach(function(item, i) {
53+
containDeep(actual[i], item);
54+
});
55+
} else if (expected && typeof expected === 'object') {
56+
assert.ok(actual && typeof actual === 'object');
57+
Object.keys(expected).forEach(function(key) {
58+
containDeep(actual[key], expected[key]);
59+
});
60+
} else {
61+
assert.strictEqual(actual, expected);
62+
}
63+
}

test/parse.js

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var parse = require('../').parse;
2-
var should = require('should');
2+
var assert = require('node:assert');
3+
var { describe, it } = require('node:test');
34

45
describe('parse(str)', function() {
56
it('should save the filename and source', function() {
@@ -8,50 +9,50 @@ describe('parse(str)', function() {
89
source: 'booty.css'
910
});
1011

11-
ast.stylesheet.source.should.equal('booty.css');
12+
assert.strictEqual(ast.stylesheet.source, 'booty.css');
1213

1314
var position = ast.stylesheet.rules[0].position;
14-
position.start.should.be.ok;
15-
position.end.should.be.ok;
16-
position.source.should.equal('booty.css');
17-
position.content.should.equal(css);
15+
assert.ok(position.start);
16+
assert.ok(position.end);
17+
assert.strictEqual(position.source, 'booty.css');
18+
assert.strictEqual(position.content, css);
1819
});
1920

2021
it('should throw when a selector is missing', function() {
21-
should(function() {
22+
assert.throws(function() {
2223
parse('{size: large}');
23-
}).throw();
24+
});
2425

25-
should(function() {
26+
assert.throws(function() {
2627
parse('b { color: red; }\n{ color: green; }\na { color: blue; }');
27-
}).throw();
28+
});
2829
});
2930

3031
it('should throw when a broken comment is found', function () {
31-
should(function() {
32+
assert.throws(function() {
3233
parse('thing { color: red; } /* b { color: blue; }');
33-
}).throw();
34+
});
3435

35-
should(function() {
36+
assert.throws(function() {
3637
parse('/*');
37-
}).throw();
38+
});
3839

3940
/* Nested comments should be fine */
40-
should(function() {
41+
assert.doesNotThrow(function() {
4142
parse('/* /* */');
42-
}).not.throw();
43+
});
4344
});
4445

4546
it('should allow empty property value', function() {
46-
should(function() {
47+
assert.doesNotThrow(function() {
4748
parse('p { color:; }');
48-
}).not.throw();
49+
});
4950
});
5051

5152
it('should not throw with silent option', function () {
52-
should(function() {
53+
assert.doesNotThrow(function() {
5354
parse('thing { color: red; } /* b { color: blue; }', { silent: true });
54-
}).not.throw();
55+
});
5556
});
5657

5758
it('should list the parsing errors and continue parsing', function() {
@@ -61,18 +62,18 @@ describe('parse(str)', function() {
6162
});
6263

6364
var rules = result.stylesheet.rules;
64-
rules.length.should.be.above(2);
65+
assert.ok(rules.length > 2);
6566

6667
var errors = result.stylesheet.parsingErrors;
67-
errors.length.should.equal(2);
68+
assert.strictEqual(errors.length, 2);
6869

69-
errors[0].should.have.a.property('message');
70-
errors[0].should.have.a.property('reason');
71-
errors[0].should.have.a.property('filename');
72-
errors[0].filename.should.equal('foo.css');
73-
errors[0].should.have.a.property('line');
74-
errors[0].should.have.a.property('column');
75-
errors[0].should.have.a.property('source');
70+
assert.ok('message' in errors[0]);
71+
assert.ok('reason' in errors[0]);
72+
assert.ok('filename' in errors[0]);
73+
assert.strictEqual(errors[0].filename, 'foo.css');
74+
assert.ok('line' in errors[0]);
75+
assert.ok('column' in errors[0]);
76+
assert.ok('source' in errors[0]);
7677

7778
});
7879

@@ -81,28 +82,28 @@ describe('parse(str)', function() {
8182
'thing { test: value; }\n' +
8283
'@media (min-width: 100px) { thing { test: value; } }');
8384

84-
should(result.parent).equal(null);
85+
assert.strictEqual(result.parent, null);
8586

8687
var rules = result.stylesheet.rules;
87-
rules.length.should.equal(2);
88+
assert.strictEqual(rules.length, 2);
8889

8990
var rule = rules[0];
90-
rule.parent.should.equal(result);
91-
rule.declarations.length.should.equal(1);
91+
assert.strictEqual(rule.parent, result);
92+
assert.strictEqual(rule.declarations.length, 1);
9293

9394
var decl = rule.declarations[0];
94-
decl.parent.should.equal(rule);
95+
assert.strictEqual(decl.parent, rule);
9596

9697
var media = rules[1];
97-
media.parent.should.equal(result);
98-
media.rules.length.should.equal(1);
98+
assert.strictEqual(media.parent, result);
99+
assert.strictEqual(media.rules.length, 1);
99100

100101
rule = media.rules[0];
101-
rule.parent.should.equal(media);
102+
assert.strictEqual(rule.parent, media);
102103

103-
rule.declarations.length.should.equal(1);
104+
assert.strictEqual(rule.declarations.length, 1);
104105
decl = rule.declarations[0];
105-
decl.parent.should.equal(rule);
106+
assert.strictEqual(decl.parent, rule);
106107
});
107108

108109
});

0 commit comments

Comments
 (0)