Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hironichu/denosass
Browse files Browse the repository at this point in the history
  • Loading branch information
hironichu committed Mar 25, 2022
2 parents bba3803 + fd5f81a commit 4cec5a0
Show file tree
Hide file tree
Showing 12 changed files with 1,300 additions and 565 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/deno.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# This workflow will install Deno then run Deno lint and test.
# For more information see: https://github.com/denoland/setup-deno

name: Deno

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Setup repo
uses: actions/checkout@v2

- name: Setup Deno
# uses: denoland/setup-deno@v1
uses: denoland/setup-deno@004814556e37c54a2f6e31384c9e18e983317366
with:
deno-version: v1.x

# Uncomment this step to verify the use of 'deno fmt' on each commit.
- name: Verify formatting
run: deno fmt --check

- name: Run linter
run: deno lint

- name: Run tests
run: deno test -A --unstable
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"url": "http://localhost:5500"
}
]
}
}
69 changes: 37 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ denosass compile
body {
color:red;
}
body{color:red}%

body{color:red}%
```

Please note that if the output folder doesn't exist, Denosass will create it, if
Expand Down Expand Up @@ -90,16 +89,16 @@ const compiler = sass(`
`);
```

sass take an optional object as an argument, which contains the ability to set the format for the next function call (.to_string..)
here is an example :
sass take an optional object as an argument, which contains the ability to set
the format for the next function call (.to_string..) here is an example :

```ts
const from_files = sass(`...`, {
//The load_paths will allow you to import files that are somewhere else in your system, note that this feature is still unstable !
load_paths: ["some/relative/path", "/or/absolute/include/path"],
quiet: true,// Optional, Define if you want to see Sass warning or not.
style: "compressed"//Optional, by default "compressed" is selected.
}
)
//The load_paths will allow you to import files that are somewhere else in your system, note that this feature is still unstable !
load_paths: ["some/relative/path", "/or/absolute/include/path"],
quiet: true, // Optional, Define if you want to see Sass warning or not.
style: "compressed", //Optional, by default "compressed" is selected.
});
```

Once you're done, call one of the function, if you don't set a format, the
Expand Down Expand Up @@ -166,44 +165,50 @@ compiler.to_file({

As of today, some feature are not available in browsers, (such as files/folder),
I need to edit some stuff so the Deno namespace doesn't stop the code from
running in modern browsers, but it should work as the older one did.
g
running in modern browsers, but it should work as the older one did. g

## Deploy

This module should work today, with the entire featureset on Deploy

## Core API
By default, i made a wrapper around the function exported form the Wasm code, this is because I want to have some nice feature around (such as multiple file support, export to file/buffer etc...)

however you can directly use these functions if you don't need the additional features.
By default, i made a wrapper around the function exported form the Wasm code,
this is because I want to have some nice feature around (such as multiple file
support, export to file/buffer etc...)

however you can directly use these functions if you don't need the additional
features.

```ts
import { str, file } from "./wasm/grass.deno.js";
import { file, str } from "./wasm/grass.deno.js";

//From a string, note that it will resolve any imported module from import.meta.url (the current dir of the typescript file being executed.)
const fromstr = str(`
const fromstr = str(
`
@import 'superlib';
`,
{
load_paths: [
"./libscss",
"/Users/ekko/Documents/testscss"
],
style: "expanded",
quiet: true
});
console.log(fromstr)
{
load_paths: [
"./libscss",
"/Users/ekko/Documents/testscss",
],
style: "expanded",
quiet: true,
},
);
console.log(fromstr);

//And from a file
const fromfile = file(`./myscss/myscss.scss`,
{
const fromfile = file(`./myscss/myscss.scss`, {
load_paths: [
"./libscss",
"/Users/ekko/Documents/testscss"
],
style: "expanded",
quiet: true
"/Users/ekko/Documents/testscss",
],
style: "expanded",
quiet: true,
});
console.log(fromfile)
console.log(fromfile);
///
```

Expand Down
6 changes: 3 additions & 3 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sass from "./mod.ts";
import { SassFormats } from "./src/types/module.types.ts";
import { parse as CMDParse } from "https://deno.land/[email protected]/flags/mod.ts";
import { readAll } from "https://deno.land/std/streams/conversion.ts "
import { readAll } from "https://deno.land/std/streams/conversion.ts ";
const readPerm = { name: "read" } as const;
const writePerm = { name: "write" } as const;
const envPerm = { name: "env" } as const;
Expand Down Expand Up @@ -68,7 +68,7 @@ if (import.meta.main) {
if (paths && typeof paths === "string") {
include_paths = paths.split(",");
} else {
include_paths = ["./"]
include_paths = ["./"];
}
const stdin = await readAll(Deno.stdin);
const sass_result = sass(stdin, {
Expand Down Expand Up @@ -104,7 +104,7 @@ if (import.meta.main) {
if (paths && typeof paths === "string") {
include_paths = paths.split(",");
} else {
include_paths = ["./"]
include_paths = ["./"];
}
const SassData = sass(parsed._ as string[], {
load_paths: include_paths,
Expand Down
27 changes: 27 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{

"lint": {
"files": {
"include": ["src/"],
"exclude": ["src/wasm"]
},
"rules": {
"tags": ["recommended"],
"include": ["ban-untagged-todo"],
"exclude": ["no-unused-vars"]
}
},
"fmt": {
"files": {
"include": ["src/"],
"exclude": ["src/wasm/"]
},
"options": {
"useTabs": false,
"lineWidth": 80,
"indentWidth": 2,
"singleQuote": true,
"proseWrap": "preserve"
}
}
}
5 changes: 5 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//This file maybe temporary.
//TODO(@hironichu): Make a proper API to compile SASS to CSS.
//
export { str } from './wasm/grass.browser.js';
//
9 changes: 4 additions & 5 deletions src/deps.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
export * as denosass from "./wasm/grass.deno.js";
export * from "https://deno.land/std@0.119.0/testing/asserts.ts";
export * as denosass from './wasm/grass.deno.js';
export * from 'https://deno.land/std@0.131.0/testing/asserts.ts';
export {
emptyDirSync,
ensureDirSync,
walkSync,
} from "https://deno.land/[email protected]/fs/mod.ts";
export * as path from "https://deno.land/[email protected]/path/mod.ts";

} from 'https://deno.land/[email protected]/fs/mod.ts';
export * as path from 'https://deno.land/[email protected]/path/mod.ts';
Loading

0 comments on commit 4cec5a0

Please sign in to comment.