Skip to content

Commit

Permalink
[fix] Formatting synchronization has been changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulyanov-programmer committed Oct 10, 2024
1 parent a1a411a commit dc17495
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cssToHtml.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import fs from 'fs-extra'
import path from 'path'
import prettier from "@prettier/sync"
import { createSyncFn } from 'synckit'
import { parse } from '@adobe/css-tools'
import { createParser } from 'css-selector-parser'
import { ElementOfHtml } from './elementOfHtml.js'

const syncFormatting = createSyncFn(path.resolve('./formatWorker.js'))

export class CssToHtml {
static ENCODING = 'utf8'
Expand Down Expand Up @@ -113,7 +114,7 @@ export class CssToHtml {
}

if (this.format) {
return prettier.format(newContent, { parser: "html" })
return syncFormatting(newContent)
} else {
return newContent
}
Expand Down
6 changes: 6 additions & 0 deletions formatWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { runAsWorker } from 'synckit'
import * as prettier from "prettier"

runAsWorker(async (newContent) => {
return prettier.format(newContent, { parser: "html" })
})
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
],
"dependencies": {
"@adobe/css-tools": "^4.4.0",
"@prettier/sync": "^0.5.2",
"css-selector-parser": "^3.0.5",
"fs-extra": "^11.2.0",
"prettier": "^3.3.3"
"prettier": "^3.3.3",
"synckit": "^0.9.2"
},
"license": "ISC"
}

0 comments on commit dc17495

Please sign in to comment.