Skip to content
This repository was archived by the owner on Apr 8, 2023. It is now read-only.

Commit 80cc09f

Browse files
committed
build: use csscomb from github
1 parent 95b202b commit 80cc09f

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "csscomb.js"]
2+
path = csscomb.js
3+
url = https://github.com/csscomb/csscomb.js
4+
branch = dev

.vscodeignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ tslint.json
1111
.vscode/**
1212
src/**
1313
smoke/**
14+
15+
# csscomb submodule
16+
csscomb.js/**
17+
!csscomb.js/config
18+
!csscomb.js/lib

csscomb.js

Submodule csscomb.js added at ce7ad83

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@
114114
"lint": "tslint src/**/*.ts -p .",
115115
"compile": "tsc",
116116
"test": "mocha out/{,**/}*.spec.js -s 0",
117-
"build": "npm run clean && npm run lint && npm run compile && npm test",
117+
"csscomb:build": "cd ./csscomb.js && node ./node_modules/@babel/cli/bin/babel.js --plugins @babel/plugin-transform-destructuring --loose all src --out-dir lib",
118+
"csscomb:prepare": "cd ./csscomb.js && npm ci --ignore-scripts",
119+
"build:plugin": "npm run clean && npm run lint && npm run compile && npm test",
120+
"build:csscomb": "npm run csscomb:prepare && npm run csscomb:build",
121+
"build": "npm run build:csscomb && npm run build:plugin",
118122
"watch": "npm run clean && npm run lint && npm run compile -- --sourceMap --watch"
119123
}
120124
}

src/services/csscomb.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
1-
import * as CSSComb from 'csscomb';
1+
// @ts-ignore
2+
import * as CSSComb from '../../csscomb.js/lib/csscomb.js';
3+
4+
interface IProcessOptions {
5+
filename?: string;
6+
context?: string;
7+
syntax: string;
8+
}
9+
10+
declare class CSSCombConstructor {
11+
constructor(config: string | object);
12+
public static getConfig(name: string): object;
13+
public configure(config: object): void;
14+
public processString(text: string, options: IProcessOptions): Promise<string>;
15+
}
16+
17+
type CSSComb = typeof CSSCombConstructor;
218

319
const DEFAULT_CONFIGS = {
4-
csscomb: CSSComb.getConfig('csscomb'),
5-
yandex: CSSComb.getConfig('yandex'),
6-
zen: CSSComb.getConfig('zen')
20+
csscomb: (CSSComb as CSSComb).getConfig('csscomb'),
21+
yandex: (CSSComb as CSSComb).getConfig('yandex'),
22+
zen: (CSSComb as CSSComb).getConfig('zen')
723
};
824

925
/**
1026
* Apply CSSComb to the given text with provided config.
1127
*/
1228
export function use(filename: string, text: string, syntax: string, config: object): Promise<string> {
13-
const csscomb = new CSSComb(config);
29+
const csscomb = new (CSSComb as CSSComb)(config);
1430

1531
return csscomb.processString(text, { syntax, filename });
1632
}

0 commit comments

Comments
 (0)