Skip to content

Commit

Permalink
build: fix shaker on Windows platform
Browse files Browse the repository at this point in the history
Comparing subpaths with strings is not reliable, as Windows uses a
different path separator. Use path.relative instead and test for '..'.

Fixes: #432
  • Loading branch information
ChALkeR committed May 2, 2018
1 parent 0cf407a commit cae3cf1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions builder/shaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const path = require("path");

const root = path.dirname(__dirname);
const prefix = "src/modules/";
const QtGlobal = "src/modules/QtQml/Qt.js";
const QtGlobal = path.normalize("QtQml/Qt.js");

function baseClass(file) {
const buffer = file.contents;
Expand Down Expand Up @@ -46,10 +46,10 @@ module.exports = function(options = {}) {
const shake = [];

function onFile(file) {
const relative = path.relative(root, file.path);
if (relative.startsWith(prefix) && relative !== QtGlobal) {
const filename = path.relative(path.join(root, prefix), file.path);
const name = filename.replace(".js", "").split("/").join(".");
const filename = path.relative(path.join(root, prefix), file.path);
if (!filename.includes("..") && filename !== QtGlobal) {
// Process all files inside the `prefix`, except for the Qt.js file
const name = filename.replace(".js", "").split(/[\\/]/).join(".");
const module = name.replace(/.[^.]+$/, ""); // "A.B.C" -> "A.B"
try {
const base = baseClass(file);
Expand Down

0 comments on commit cae3cf1

Please sign in to comment.