Updates
This commit is contained in:
parent
e6e2fa65cb
commit
de8191edca
8
dist/index.d.ts
vendored
Normal file
8
dist/index.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
export type LessCssWatcherConfigObject = {
|
||||
src?: string | string[];
|
||||
dst?: string | string[];
|
||||
srcDst?: {
|
||||
src?: string;
|
||||
dst?: string;
|
||||
}[];
|
||||
};
|
32
dist/index.js
vendored
32
dist/index.js
vendored
@ -1,4 +1,3 @@
|
||||
#! /usr/bin/env node
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
@ -74,6 +73,9 @@ const grabSrcDisStrings = () => {
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
return {
|
||||
sourceFile: srcArray.join(","),
|
||||
destinationFile: dstArray.join(","),
|
||||
@ -83,11 +85,20 @@ const { sourceFile, destinationFile } = grabSrcDisStrings();
|
||||
if (sourceFile && destinationFile) {
|
||||
process.argv.push("--src", sourceFile, "--dst", destinationFile);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
console.log("- \x1b[35mStart:\x1b[0m Running Less compiler ...");
|
||||
if (!sourceFile || !destinationFile) {
|
||||
console.log("- \x1b[31mERROR:\x1b[0m => Missing source or destination file");
|
||||
process.exit();
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Loop through source files and destination files and run the compile function
|
||||
*/
|
||||
function traverseFiles(src, dst) {
|
||||
var _a;
|
||||
const sourceFiles = src.split(",");
|
||||
@ -196,6 +207,16 @@ function traverseFiles(src, dst) {
|
||||
}
|
||||
}
|
||||
traverseFiles(sourceFile, destinationFile);
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Compile less file to css function
|
||||
* @param fileName - less file path or folder path
|
||||
* @param dst - destination file path or folder path
|
||||
* @param evtType - event type (change, rename, etc.) or null
|
||||
* @returns
|
||||
*/
|
||||
function compile(fileName, dst, evtType) {
|
||||
if ((fileName === null || fileName === void 0 ? void 0 : fileName.match(/\(/)) ||
|
||||
(fileName.match(/\.[\/]$/) && !(fileName === null || fileName === void 0 ? void 0 : fileName.match(/\.less$/i)))) {
|
||||
@ -220,8 +241,9 @@ function compile(fileName, dst, evtType) {
|
||||
finalSrcPath = fileName;
|
||||
finalDstPath = targetDstFilePath;
|
||||
}
|
||||
const executionCmd = `lessc ${finalSrcPath} ${finalDstPath}`;
|
||||
const executionCmd = `npx lessc ${finalSrcPath} ${finalDstPath}`;
|
||||
(0, child_process_1.exec)(executionCmd, (error, stdout, stderr) => {
|
||||
/** @type {Error} */
|
||||
if (error) {
|
||||
console.log("- \x1b[33mWarn:\x1b[0m Compilation didn't run successfully. ERROR =>", error.message);
|
||||
if (!(evtType === null || evtType === void 0 ? void 0 : evtType.match(/change/i)) &&
|
||||
@ -234,6 +256,12 @@ function compile(fileName, dst, evtType) {
|
||||
console.log("- \x1b[32mCompiled:\x1b[0m Less Compilation Successful!");
|
||||
});
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* watch for changes to the config file
|
||||
*/
|
||||
if (fs_1.default.existsSync("./lesscw.config.json")) {
|
||||
fs_1.default.watchFile("./lesscw.config.json", { interval: 500 }, (evtType, fileName) => {
|
||||
console.log("- \x1b[34mInfo:\x1b[0m Restarting process...");
|
||||
|
1
dist/tsconfig.tsbuildinfo
vendored
Normal file
1
dist/tsconfig.tsbuildinfo
vendored
Normal file
File diff suppressed because one or more lines are too long
59
package.json
59
package.json
@ -1,30 +1,31 @@
|
||||
{
|
||||
"name": "lessc-watcher",
|
||||
"version": "1.2.2",
|
||||
"description": "A minimal package to watch less files and compile them to css",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
"lessc-watcher": "./dist/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/BenjaminToby/less-watcher.git"
|
||||
},
|
||||
"keywords": [
|
||||
"less",
|
||||
"watcher",
|
||||
"css"
|
||||
],
|
||||
"author": "Benjamin Toby",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.4.5",
|
||||
"@types/bun": "latest"
|
||||
},
|
||||
"dependencies": {
|
||||
"less": "^4.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
}
|
||||
}
|
||||
"name": "@moduletrace/less-watcher",
|
||||
"version": "1.0.1",
|
||||
"description": "A minimal package to watch less files and compile them to css",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
"lessc-watcher": "dist/index.js",
|
||||
"less-watcher": "dist/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.tben.me/Moduletrace/less-watcher.git"
|
||||
},
|
||||
"keywords": [
|
||||
"less",
|
||||
"watcher",
|
||||
"css"
|
||||
],
|
||||
"author": "Benjamin Toby",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.4.5",
|
||||
"@types/bun": "latest"
|
||||
},
|
||||
"dependencies": {
|
||||
"less": "^4.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
}
|
||||
}
|
||||
|
0
publish.sh
Normal file → Executable file
0
publish.sh
Normal file → Executable file
Loading…
Reference in New Issue
Block a user