Skip to content

Commit

Permalink
Merge pull request #76 from danielnaab/package-json-paths
Browse files Browse the repository at this point in the history
Use require.resolve() to find the uswds package path
  • Loading branch information
thisisdano authored Nov 15, 2023
2 parents c0f3209 + 910cc2e commit eff4198
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -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"));
Expand Down Expand Up @@ -150,13 +151,18 @@ function logVersion() {
return Promise.resolve("logged version");
}

function buildSass() {
let uswdsPath = "uswds";
function getUswdsVersion() {
let uswdsPackage = "uswds";
if (settings.version === 3) {
uswdsPath = "@uswds/uswds";
uswdsPackage = "@uswds/uswds";
}
const packagePath = path.join(path.dirname(require.resolve(uswdsPackage)), '../../');
const version = require(`${packagePath}/package.json`).version;
return version;
}

const pkg = require(`../../${uswdsPath}/package.json`).version;
function buildSass() {
const pkg = getUswdsVersion();

log(colors.blue, `Compiling with USWDS ${pkg}`);
const buildSettings = {
Expand Down

0 comments on commit eff4198

Please sign in to comment.