updates
This commit is contained in:
parent
e3498601a1
commit
1ac9bb4fbe
15
dist/index.js
vendored
15
dist/index.js
vendored
@ -103,6 +103,14 @@ function traverseFiles(src, dst) {
|
||||
}
|
||||
}
|
||||
compile(srcFolder, dstFile, null);
|
||||
try {
|
||||
fs_1.default.readdirSync(srcFolder).forEach((file) => {
|
||||
if (file === null || file === void 0 ? void 0 : file.match(/^\[.*\.less$/)) {
|
||||
compile(srcFolder + "/" + file, dstFile, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) { }
|
||||
if (srcFolder === null || srcFolder === void 0 ? void 0 : srcFolder.match(/\.less$/)) {
|
||||
fs_1.default.watchFile(srcFolder, { interval: 500 }, (current, previous) => {
|
||||
const dstFilePathRoot = (dstFile === null || dstFile === void 0 ? void 0 : dstFile.match(/\.css$/)) ? dstFile : dstFile + "/" + "_main.css";
|
||||
@ -132,7 +140,10 @@ function traverseFiles(src, dst) {
|
||||
try {
|
||||
const currentProcessArgsSrc = process.argv[process.argv.indexOf("--src") + 1];
|
||||
const activeSourceFiles = currentProcessArgsSrc.split(",");
|
||||
if (activeSourceFiles.includes(srcFilePathRoot)) {
|
||||
if (fileName === null || fileName === void 0 ? void 0 : fileName.match(/^\[/)) {
|
||||
compile(srcFolder + "/" + fileName, dstFile, evtType);
|
||||
}
|
||||
else if ((fileName === null || fileName === void 0 ? void 0 : fileName.match(/^\(/)) || activeSourceFiles.includes(srcFilePathRoot)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@ -167,7 +178,7 @@ function compile(fileName, dst, evtType) {
|
||||
const targetPath = targetPathFull.replace(/\[|\]/g, "").replace(/\.less/, "");
|
||||
const destinationFileParentFolder = dst.replace(/\/[^\/]+\.css$/, "");
|
||||
const targetDstFilePath = `${destinationFileParentFolder}/${targetPath}.css`;
|
||||
finalSrcPath = `${fileName}/${targetPathFull}`;
|
||||
finalSrcPath = fileName;
|
||||
finalDstPath = targetDstFilePath;
|
||||
}
|
||||
const executionCmd = `lessc ${finalSrcPath} ${finalDstPath}`;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lessc-watcher",
|
||||
"version": "1.1.7",
|
||||
"version": "1.1.8",
|
||||
"description": "A minimal package to watch less files and compile them to css",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
18
src/index.ts
18
src/index.ts
@ -1,7 +1,7 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
import fs, { watch } from "fs";
|
||||
import { exec, spawn } from "child_process";
|
||||
import fs from "fs";
|
||||
import { exec } from "child_process";
|
||||
import { LessCssWatcherConfigObject } from "./index.d";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -125,6 +125,14 @@ function traverseFiles(src: string, dst: string) {
|
||||
|
||||
compile(srcFolder, dstFile, null);
|
||||
|
||||
try {
|
||||
fs.readdirSync(srcFolder).forEach((file) => {
|
||||
if (file?.match(/^\[.*\.less$/)) {
|
||||
compile(srcFolder + "/" + file, dstFile, null);
|
||||
}
|
||||
});
|
||||
} catch (error) {}
|
||||
|
||||
if (srcFolder?.match(/\.less$/)) {
|
||||
fs.watchFile(srcFolder, { interval: 500 }, (current, previous) => {
|
||||
const dstFilePathRoot = dstFile?.match(/\.css$/) ? dstFile : dstFile + "/" + "_main.css";
|
||||
@ -156,7 +164,9 @@ function traverseFiles(src: string, dst: string) {
|
||||
const currentProcessArgsSrc = process.argv[process.argv.indexOf("--src") + 1];
|
||||
const activeSourceFiles = currentProcessArgsSrc.split(",");
|
||||
|
||||
if (activeSourceFiles.includes(srcFilePathRoot)) {
|
||||
if (fileName?.match(/^\[/)) {
|
||||
compile(srcFolder + "/" + fileName, dstFile, evtType);
|
||||
} else if (fileName?.match(/^\(/) || activeSourceFiles.includes(srcFilePathRoot)) {
|
||||
return;
|
||||
} else {
|
||||
compile(srcFilePathRoot, dstFile, evtType);
|
||||
@ -207,7 +217,7 @@ function compile(fileName: string, dst: string, evtType: string | null) {
|
||||
|
||||
const targetDstFilePath = `${destinationFileParentFolder}/${targetPath}.css`;
|
||||
|
||||
finalSrcPath = `${fileName}/${targetPathFull}`;
|
||||
finalSrcPath = fileName;
|
||||
finalDstPath = targetDstFilePath;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user