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

Turn Project into Typescript PR #172

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion less-watch-compiler.sample.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"allowedExtensions":[".less"],
"enableJs": true,
"enableJs": false,
"minified": true,
"includeHidden": true,
"sourceMap": true,
Expand Down
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "less-watch-compiler",
"version": "1.16.2",
"description": "A command that watches folders(and subfolders) for file changes and automatically compile the less css files into css. This is a file system watcher and compiler.",
"main": "dist/less-watch-compiler.js",
"main": "dist/main.js",
"directories": {
"test": "tests"
},
Expand All @@ -15,8 +15,8 @@
"clean": "rm -R ./test/css || true && mkdir ./test/css",
"prepublishOnly": "yarn run build",
"commit": "git-cz -n",
"build": "babel src --out-dir dist",
"start": "yarn run build && node ./dist/less-watch-compiler.js",
"build": "./node_modules/typescript/bin/tsc",
"start": "yarn run build && node ./dist/main.js",
"postinstall": "opencollective-postinstall"
},
"repository": {
Expand All @@ -37,11 +37,15 @@
},
"engine": "node 0.10.26",
"devDependencies": {
"@types/commander": "2.12.2",
"@types/commander": "^2.12.2",
"@types/extend": "^3.0.1",
"@types/node": "^16.3.2",
"@types/shelljs": "^0.8.9",
"babel-cli": "6.26.0",
"babel-preset-env": "1.7.0",
"cz-conventional-changelog": "3.3.0",
"mocha": "9.0.3"
"mocha": "9.0.3",
"typescript": "^4.3.5"
},
"preferGlobal": true,
"keywords": [
Expand Down
174 changes: 0 additions & 174 deletions src/less-watch-compiler.js

This file was deleted.

75 changes: 75 additions & 0 deletions src/lib/Options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { OptionValues } from "commander";

export class Options {
private static instance: Options;

inputOptions: OptionValues = [];
config: string = "";
watchFolder: string = "";
outputFolder: string = "";
mainFile: string = "";
sourceMap: boolean = false;
plugins: string = "";
runOnce: boolean = false;
includeHidden: boolean = false;
enableJs: boolean = false;
lessArgs: string = "";
minified: boolean = false;
allowedExtensions: string[] = [".less"];

private constructor(options?: OptionValues) {
if (options) this.setValues(options);
}

private setValues(options: OptionValues|undefined) {
if (options !== undefined){

this.inputOptions = options;
this.config = options.config;
this.watchFolder = options.args[0];
this.outputFolder = options.args[1];
this.mainFile = options.mainFile || options.args[2];
this.sourceMap = options.sourceMap;
this.plugins = options.plugins;
this.runOnce = options.runOnce;
this.includeHidden = options.includeHidden;
this.enableJs = options.enableJs;
this.lessArgs = options.lessArgs;
this.minified = options.minified;
this.allowedExtensions = [".less"];
}
}
public setValue(key:string, value:any):Options|boolean {
if (key in this){
[key] = value;
return Options.instance;
}else{
return false;
}

}
public reset():void {
this.inputOptions = [];
this.config = '';
this.watchFolder = '';
this.outputFolder = '';
this.mainFile = '';
this.sourceMap = false;
this.plugins = '';
this.runOnce = false;
this.includeHidden = false;
this.enableJs = false;
this.lessArgs = '';
this.minified = false;
}

public static getInstance(options?: OptionValues): Options {
if (!Options.instance) {
Options.instance = new Options(options);
}else{
Options.instance.setValues(options);
}

return Options.instance;
}
}
Loading