Created
July 14, 2021 18:01
-
-
Save jodyheavener/bf60cafdf6b3dcdd49984c8a31f1bbab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/packages/fxa-auth-server/lib/senders/emails/sass-compile-files.ts b/packages/fxa-auth-server/lib/senders/emails/sass-compile-files.ts | |
index 3551fe3e7..d2885e173 100644 | |
--- a/packages/fxa-auth-server/lib/senders/emails/sass-compile-files.ts | |
+++ b/packages/fxa-auth-server/lib/senders/emails/sass-compile-files.ts | |
@@ -2,17 +2,16 @@ | |
* License, v. 2.0. If a copy of the MPL was not distributed with this | |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
-import sass from 'sass'; | |
-import { promisify } from 'util'; | |
-import { writeFile, mkdir, existsSync, rmdir, readdirSync } from 'fs'; | |
+import { renderSync } from 'sass'; | |
+import { | |
+ writeFileSync, | |
+ mkdirSync, | |
+ existsSync, | |
+ rmdirSync, | |
+ readdirSync, | |
+} from 'fs'; | |
import path from 'path'; | |
-// promisify the functions in favor of async/await syntax | |
-const sassRenderPromise = promisify(sass.render); | |
-const writeFilePromise = promisify(writeFile); | |
-const makeDirPromise = promisify(mkdir); | |
-const removeDirPromise = promisify(rmdir); | |
- | |
const getDirectories = (source: string) => | |
readdirSync(source, { withFileTypes: true }) | |
.filter((dirent: any) => dirent.isDirectory()) | |
@@ -24,26 +23,25 @@ const templates = getDirectories(path.join(__dirname, `templates`)); | |
/* @ts-ignore */ | |
async function compileSass(dir, subdir) { | |
- const styleResult = await sassRenderPromise({ | |
+ const styleResult = renderSync({ | |
file: dir, | |
outFile: subdir, | |
}); | |
- await writeFilePromise(subdir, styleResult.css, 'utf8'); | |
+ writeFileSync(subdir, styleResult.css, 'utf8'); | |
} | |
-/* @ts-ignore */ | |
async function main(directories) { | |
// remove css directory if already present | |
if (existsSync(path.join(__dirname, `css`))) { | |
- await removeDirPromise(path.join(__dirname, `css`), { recursive: true }); | |
+ rmdirSync(path.join(__dirname, `css`), { recursive: true }); | |
} | |
- await makeDirPromise(path.join(__dirname, `css`)); | |
+ mkdirSync(path.join(__dirname, `css`)); | |
// create subdirectories for templates and partials inside the css directory and generate compiled stylesheets into them | |
for (const dir in directories) { | |
for (const subdir of directories[`${dir}`]) { | |
- await makeDirPromise(path.join(__dirname, `css`, subdir)); | |
+ mkdirSync(path.join(__dirname, `css`, subdir)); | |
const scssPath = path.join(__dirname, dir, subdir, `index.scss`); | |
const cssPath = path.join(__dirname, `css`, subdir, `index.css`); | |
await compileSass(scssPath, cssPath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment