Comparing version 1.4.1 to 1.4.2
@@ -0,1 +1,11 @@ | ||
<a name="1.4.2"></a> | ||
## [1.4.2](https://github.com/kei-ito/esifycss/compare/v1.4.1...v1.4.2) (2020-01-18) | ||
### Bug Fixes | ||
* generatescript ([#57](https://github.com/kei-ito/esifycss/issues/57)) ([cf1855b](https://github.com/kei-ito/esifycss/commit/cf1855b)) | ||
<a name="1.4.1"></a> | ||
@@ -2,0 +12,0 @@ ## [1.4.1](https://github.com/kei-ito/esifycss/compare/v1.4.0...v1.4.1) (2020-01-18) |
@@ -8,3 +8,2 @@ "use strict"; | ||
const setDictionary_1 = require("./setDictionary"); | ||
const removeAddStyle_1 = require("./removeAddStyle"); | ||
exports.minifyScripts = async (output, files) => { | ||
@@ -29,5 +28,6 @@ const parseResult = await parseScripts_1.parseScripts(files); | ||
cssList[index] = range.css; | ||
code = `${code.slice(0, range.start)}${code.slice(range.end).replace(/^\s*,\s*/, '')}`; | ||
code = `${code.slice(0, range.start)}'CSS${index}'${code.slice(range.end)}`; | ||
} | ||
await fs_1.writeFile(file, removeAddStyle_1.removeAddStyle(code)); | ||
code = code.replace(/^\s*\[\s*('CSS\d+',?\s*)*\]\s*;\s*?[\r\n]/g, ''); | ||
await fs_1.writeFile(file, code); | ||
return cssList.join('\n'); | ||
@@ -34,0 +34,0 @@ })); |
@@ -6,2 +6,3 @@ /// <reference types="node" /> | ||
import { write } from '../util/write'; | ||
import { IExposedPromise } from '../util/createExposedPromise'; | ||
export declare class Session { | ||
@@ -12,3 +13,3 @@ readonly configuration: Readonly<ISessionConfiguration>; | ||
protected initialTask: Array<Promise<void>> | null; | ||
protected previousProcess?: Promise<void>; | ||
protected tasks: Set<Promise<void>>; | ||
constructor(parameters?: ISessionOptions); | ||
@@ -24,2 +25,4 @@ get helperPath(): string; | ||
minifyScripts(): Promise<void>; | ||
protected waitCurrentTasks(): Promise<void>; | ||
protected createExposedPromise(): IExposedPromise; | ||
protected startWatcher(): Promise<void>; | ||
@@ -26,0 +29,0 @@ protected log(...messages: Parameters<typeof write>[1]): void; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const fs_1 = require("../util/fs"); | ||
const generateScript_1 = require("../scriptGenerator/generateScript"); | ||
const generateScript_1 = require("./generateScript"); | ||
const waitForInitialScanCompletion_1 = require("./waitForInitialScanCompletion"); | ||
@@ -20,2 +20,3 @@ const minifyScripts_1 = require("../minifier/minifyScripts"); | ||
this.initialTask = null; | ||
this.tasks = new Set(); | ||
} | ||
@@ -39,8 +40,10 @@ get helperPath() { | ||
async processCSS(filePath) { | ||
await this.previousProcess; | ||
const exposedPromise = createExposedPromise_1.createExposedPromise(); | ||
this.previousProcess = exposedPromise.promise; | ||
if (0 < this.tasks.size) { | ||
await this.waitCurrentTasks(); | ||
} | ||
const exposedPromise = this.createExposedPromise(); | ||
const { configuration } = this; | ||
const postcssResult = await parseCSS_1.parseCSS({ | ||
plugins: this.configuration.postcssPlugins, | ||
options: this.configuration.postcssOptions, | ||
plugins: configuration.postcssPlugins, | ||
options: configuration.postcssOptions, | ||
file: filePath, | ||
@@ -52,8 +55,13 @@ }) | ||
}); | ||
const pluginResult = extractPluginResult_1.extractPluginResult(postcssResult); | ||
const outputPath = path.join(`${filePath}${this.configuration.ext}`); | ||
const dest = path.join(`${filePath}${configuration.ext}`); | ||
this.processedFiles.add(filePath); | ||
const code = generateScript_1.generateScript(outputPath, this.configuration.output.path, pluginResult, postcssResult.root); | ||
const { output } = configuration; | ||
const code = generateScript_1.generateScript({ | ||
output: dest, | ||
helper: output.type === 'css' ? null : output.path, | ||
result: extractPluginResult_1.extractPluginResult(postcssResult), | ||
root: postcssResult.root, | ||
}); | ||
exposedPromise.resolve(); | ||
return { dest: outputPath, code }; | ||
return { dest, code }; | ||
} | ||
@@ -63,2 +71,14 @@ async minifyScripts() { | ||
} | ||
async waitCurrentTasks() { | ||
await Promise.all([...this.tasks]); | ||
} | ||
createExposedPromise() { | ||
const exposedPromise = createExposedPromise_1.createExposedPromise(); | ||
this.tasks.add(exposedPromise.promise); | ||
const removeTask = () => this.tasks.delete(exposedPromise.promise); | ||
exposedPromise.promise | ||
.then(removeTask) | ||
.catch(removeTask); | ||
return exposedPromise; | ||
} | ||
async startWatcher() { | ||
@@ -65,0 +85,0 @@ await this.stopWatcher(); |
{ | ||
"name": "esifycss", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Generates .js or .ts exports class names and custom properties", | ||
@@ -5,0 +5,0 @@ "author": { |
112441
1859
131