From 7f40fdfa6a12d1e34c597a8fd3119352bf3d3561 Mon Sep 17 00:00:00 2001 From: Daniel Naab Date: Wed, 18 Oct 2023 13:20:18 -0500 Subject: [PATCH 1/2] Use require.resolve() to find the uswds package path. --- gulpfile.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index f14e640..9f22b76 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,7 @@ const autoprefixer = require("autoprefixer"); const csso = require("postcss-csso"); const { src, dest, series, parallel, watch } = require("gulp"); +const path = require("path"); const postcss = require("gulp-postcss"); const replace = require("gulp-replace"); const sass = require("gulp-sass")(require("sass-embedded")); @@ -150,13 +151,23 @@ function logVersion() { return Promise.resolve("logged version"); } +function getUswdsVersion() { + let uswdsPackage = "uswds"; + if (settings.version === 3) { + uswdsPackage = "@uswds/uswds"; + } + const packagePath = path.join(path.dirname(require.resolve(uswdsPackage)), '../../'); + const version = require(`${packagePath}/package.json`).version; + return version; +} + function buildSass() { let uswdsPath = "uswds"; if (settings.version === 3) { uswdsPath = "@uswds/uswds"; } - const pkg = require(`../../${uswdsPath}/package.json`).version; + const pkg = getUswdsVersion(); log(colors.blue, `Compiling with USWDS ${pkg}`); const buildSettings = { From 910cc2eeae7612d9ec0f56c40f6ea764f25ef2cf Mon Sep 17 00:00:00 2001 From: Daniel Naab Date: Wed, 18 Oct 2023 14:33:10 -0500 Subject: [PATCH 2/2] Remove snippet that was moved to getUswdsVersion function. --- gulpfile.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 9f22b76..1617e10 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -162,11 +162,6 @@ function getUswdsVersion() { } function buildSass() { - let uswdsPath = "uswds"; - if (settings.version === 3) { - uswdsPath = "@uswds/uswds"; - } - const pkg = getUswdsVersion(); log(colors.blue, `Compiling with USWDS ${pkg}`);