Skip to content

Commit

Permalink
Remove stray require from lib/index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Oct 23, 2023
1 parent 52663ac commit 57a97b5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"scripts": {
"build": "npm run build:src && npm run build:css",
"build:css": "lessc css/nouislider.less css/nouislider.css && postcss --use postcss-import --use postcss-cssnext -o css/widgets.built.css css/widgets.css",
"build:src": "tsc --build",
"build:src": "npm run clean:src && tsc --build && npm run build:fixup-version",
"build:fixup-version": "node ./scripts/fixup-version.js",
"build:test": "tsc --build test && webpack --config test/webpack.conf.js",
"clean": "npm run clean:src",
"clean:src": "rimraf lib && rimraf tsconfig.tsbuildinfo",
Expand Down
18 changes: 18 additions & 0 deletions packages/controls/scripts/fixup-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

const fs = require("fs")

const json = JSON.parse(fs.readFileSync("package.json", "utf8"));
const version = json.version;

const index = fs.readFileSync("lib/index.js", "utf8");

const indexFixed = index.replace(
'export const version = "";',
'export const version = "' + version + '";'
);

if (indexFixed === index) {
throw new Error("Failed to insert version string into lib/index.js");
}

fs.writeFileSync("lib/index.js", indexFixed);
2 changes: 1 addition & 1 deletion packages/controls/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export * from './widget_string';
export * from './widget_description';
export * from './widget_upload';

export const version = (require('../package.json') as any).version;
export const version = "";

0 comments on commit 57a97b5

Please sign in to comment.