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

Commit

Permalink
build: use csscomb from github
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Jul 2, 2020
1 parent 95b202b commit 80cc09f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "csscomb.js"]
path = csscomb.js
url = https://github.com/csscomb/csscomb.js
branch = dev
5 changes: 5 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ tslint.json
.vscode/**
src/**
smoke/**

# csscomb submodule
csscomb.js/**
!csscomb.js/config
!csscomb.js/lib
1 change: 1 addition & 0 deletions csscomb.js
Submodule csscomb.js added at ce7ad8
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@
"lint": "tslint src/**/*.ts -p .",
"compile": "tsc",
"test": "mocha out/{,**/}*.spec.js -s 0",
"build": "npm run clean && npm run lint && npm run compile && npm test",
"csscomb:build": "cd ./csscomb.js && node ./node_modules/@babel/cli/bin/babel.js --plugins @babel/plugin-transform-destructuring --loose all src --out-dir lib",
"csscomb:prepare": "cd ./csscomb.js && npm ci --ignore-scripts",
"build:plugin": "npm run clean && npm run lint && npm run compile && npm test",
"build:csscomb": "npm run csscomb:prepare && npm run csscomb:build",
"build": "npm run build:csscomb && npm run build:plugin",
"watch": "npm run clean && npm run lint && npm run compile -- --sourceMap --watch"
}
}
26 changes: 21 additions & 5 deletions src/services/csscomb.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
import * as CSSComb from 'csscomb';
// @ts-ignore
import * as CSSComb from '../../csscomb.js/lib/csscomb.js';

interface IProcessOptions {
filename?: string;
context?: string;
syntax: string;
}

declare class CSSCombConstructor {
constructor(config: string | object);
public static getConfig(name: string): object;
public configure(config: object): void;
public processString(text: string, options: IProcessOptions): Promise<string>;
}

type CSSComb = typeof CSSCombConstructor;

const DEFAULT_CONFIGS = {
csscomb: CSSComb.getConfig('csscomb'),
yandex: CSSComb.getConfig('yandex'),
zen: CSSComb.getConfig('zen')
csscomb: (CSSComb as CSSComb).getConfig('csscomb'),
yandex: (CSSComb as CSSComb).getConfig('yandex'),
zen: (CSSComb as CSSComb).getConfig('zen')
};

/**
* Apply CSSComb to the given text with provided config.
*/
export function use(filename: string, text: string, syntax: string, config: object): Promise<string> {
const csscomb = new CSSComb(config);
const csscomb = new (CSSComb as CSSComb)(config);

return csscomb.processString(text, { syntax, filename });
}
Expand Down

0 comments on commit 80cc09f

Please sign in to comment.