Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support deno #2745

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ merge of your pull request!

**Why**:

<!-- How were these changes implemented? -->

**How**:

<!-- Have you done all of these things? -->

**Checklist**:
Expand Down
26 changes: 23 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
node_tests:
name: 'Test stylus on ${{matrix.os}} with node16'
name: 'Test stylus on ${{matrix.os}} with node18'
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
Expand All @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-node@v3
with:
# The Node.js version to configure
node-version: '16'
node-version: '18'
- name: Install npm dependencies
run: npm install
- name: Print node & npm version
Expand All @@ -36,7 +36,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [10, 12, 14, 18]
node: [10, 12, 14, 16, 20]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -96,3 +96,23 @@ jobs:
run: npm install
- name: Run nyc
run: npx nyc@latest npm run test

deno_tests:
name: 'Test stylus on ${{matrix.os}} with latest stable deno'
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
# Pull repo to test machine
- uses: actions/checkout@v3
# Configures the deno version used on GitHub-hosted runners
- uses: denoland/setup-deno@v1
with:
# Run with latest stable Deno
deno-version: v1.x
- name: Print deno version
# Output useful info for debugging.
run: deno --version
- name: Run Test
run: deno run -A deno/test.ts
33 changes: 33 additions & 0 deletions deno/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Mocha from "mocha";

import fs from "node:fs";
import path from "node:path";
import process from "node:process";

globalThis.process = process;

const mocha = new Mocha({
bail: true,
checkLeaks: true,
require: ["chai"],
reporter: "dot",
});

const testDirs = ["test/", "test/middleware/"];

testDirs.forEach((testDir) => {
fs
.readdirSync(testDir)
.filter(function (file) {
if (testDir === "test/" && file === "deno.js") return false;

return file.slice(-3) === ".js";
})
.forEach(function (file) {
mocha.addFile(path.join(testDir, file));
});
});

mocha.run(function (failures) {
process.exitCode = failures ? 1 : 0;
});
4 changes: 3 additions & 1 deletion docs/docs/js.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ stylus(str)
});
```

## .define(name, node)
## .define(name, node[, raw])

By passing a `Node`, we may define a global variable. This is useful when exposing conditional features within your library depending on the availability of another. For example the **Nib** extension library conditionally supports node-canvas, providing image generation.

Expand All @@ -89,6 +89,8 @@ Stylus also casts JavaScript values to their Stylus equivalents when possible. H
.define('families', ['Helvetica Neue', 'Helvetica', 'sans-serif'])
```

Note: In default, The JavaScript object variable will coerce to a tuple-array-like expression. For example `{ foo: 'bar', bar: 'baz' }` would become the expression `(foo 'bar') (bar 'baz')`. If you want to get a [hash object](https://stylus-lang.com/docs/hashes.html) return, please set `raw` to `true`.

These same rules apply to return values in js functions as well:

```js
Expand Down
16 changes: 8 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ layout: home
sidebar: false

title: Stylus
titleTemplate: An expressive, robust, feature-rich CSS language built for nodejs
titleTemplate: An expressive, robust, feature-rich CSS language built for Node.js

hero:
name: Stylus
text: Expressive, dynamic and robust CSSs
tagline: An expressive, robust, feature-rich CSS language built for nodejs
text: Expressive, dynamic, and robust CSS
tagline: An expressive, robust, feature-rich CSS language built for Node.js
image:
src: /logo.svg
alt: Stylus
Expand All @@ -27,12 +27,12 @@ hero:
link: https://github.com/stylus/stylus

features:
- title: Born for Nodejs
details: TJ create this project for nodejs ecosystem since 2010
- title: Born for Node.js
details: TJ created this project for the Node.js Ecosystem in 2010
- title: CSS Compatible
details: Don't like indented syntax ? ok, it's optional! You can write stylus like css-style without pain
details: Don't like indented syntax? OK, it's optional! You can write Stylus like CSS without the pain
- title: IDE support
details: Both VSCode (with stylus extension) and WebStorm (builtin) support stylus development
details: Both VSCode (with Stylus extension) and WebStorm (built in) support Stylus development
- title: All optional
details: braces, semi-colons and more can be omit in your code, keep clean and less
details: Braces, semi-colons, and more can be omitted from your code to keep it clean and smaller
---
38 changes: 28 additions & 10 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function ParseError(msg) {
* Inherit from `Error.prototype`.
*/

ParseError.prototype.__proto__ = Error.prototype;
Object.setPrototypeOf(ParseError.prototype, Error.prototype);

/**
* Initialize a new `SyntaxError` with the given `msg`.
Expand All @@ -52,4 +52,4 @@ function SyntaxError(msg) {
* Inherit from `Error.prototype`.
*/

SyntaxError.prototype.__proto__ = Error.prototype;
Object.setPrototypeOf(SyntaxError.prototype, Error.prototype);
2 changes: 1 addition & 1 deletion lib/nodes/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var Arguments = module.exports = function Arguments(){
* Inherit from `nodes.Expression.prototype`.
*/

Arguments.prototype.__proto__ = nodes.Expression.prototype;
Object.setPrototypeOf(Arguments.prototype, nodes.Expression.prototype);

/**
* Initialize an `Arguments` object with the nodes
Expand Down
2 changes: 1 addition & 1 deletion lib/nodes/atblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Atblock.prototype.__defineGetter__('nodes', function(){
* Inherit from `Node.prototype`.
*/

Atblock.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(Atblock.prototype, Node.prototype);

/**
* Return a clone of this node.
Expand Down
2 changes: 1 addition & 1 deletion lib/nodes/atrule.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var Atrule = module.exports = function Atrule(type){
* Inherit from `Node.prototype`.
*/

Atrule.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(Atrule.prototype, Node.prototype);

/**
* Check if at-rule's block has only properties.
Expand Down
4 changes: 2 additions & 2 deletions lib/nodes/binop.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ var BinOp = module.exports = function BinOp(op, left, right){
* Inherit from `Node.prototype`.
*/

BinOp.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(BinOp.prototype, Node.prototype);

/**
* Return a clone of this node.
*
*
* @return {Node}
* @api public
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/nodes/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var Block = module.exports = function Block(parent, node){
* Inherit from `Node.prototype`.
*/

Block.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(Block.prototype, Node.prototype);

/**
* Check if this block has properties..
Expand Down Expand Up @@ -77,7 +77,7 @@ Block.prototype.__defineGetter__('isEmpty', function(){

/**
* Return a clone of this node.
*
*
* @return {Node}
* @api public
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/nodes/boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ var Boolean = module.exports = function Boolean(val){
if (this.nodeName) {
this.val = !!val;
} else {
return new Boolean(val);
return new Boolean(!!val);
}
};

/**
* Inherit from `Node.prototype`.
*/

Boolean.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(Boolean.prototype, Node.prototype);

/**
* Return `this` node.
Expand Down
4 changes: 2 additions & 2 deletions lib/nodes/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ var Call = module.exports = function Call(name, args){
* Inherit from `Node.prototype`.
*/

Call.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(Call.prototype, Node.prototype);

/**
* Return a clone of this node.
*
*
* @return {Node}
* @api public
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/nodes/charset.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var Charset = module.exports = function Charset(val){
* Inherit from `Node.prototype`.
*/

Charset.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(Charset.prototype, Node.prototype);

/**
* Return @charset "val".
Expand Down
2 changes: 1 addition & 1 deletion lib/nodes/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var Comment = module.exports = function Comment(str, suppress, inline){
* Inherit from `Node.prototype`.
*/

Comment.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(Comment.prototype, Node.prototype);

/**
* Return a JSON representation of this node.
Expand Down
4 changes: 2 additions & 2 deletions lib/nodes/each.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ var Each = module.exports = function Each(val, key, expr, block){
* Inherit from `Node.prototype`.
*/

Each.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(Each.prototype, Node.prototype);

/**
* Return a clone of this node.
*
*
* @return {Node}
* @api public
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/nodes/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ Expression.prototype.__defineGetter__('hash', function(){
* Inherit from `Node.prototype`.
*/

Expression.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(Expression.prototype, Node.prototype);

/**
* Return a clone of this node.
*
*
* @return {Node}
* @api public
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/nodes/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ var Extend = module.exports = function Extend(selectors){
* Inherit from `Node.prototype`.
*/

Extend.prototype.__proto__ = Node.prototype;
Object.setPrototypeOf(Extend.prototype, Node.prototype);

/**
* Return a clone of this node.
*
*
* @return {Node}
* @api public
*/
Expand Down