Skip to content

Commit

Permalink
fix: build on windows machines (#16211)
Browse files Browse the repository at this point in the history
  • Loading branch information
catamphetamine committed Jul 17, 2023
1 parent b2b9048 commit 808adeb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install dependencies and build sequelize
- name: Install dependencies
run: yarn install --immutable
- name: Build sequelize
run: yarn build
Expand All @@ -38,6 +38,23 @@ jobs:
name: install-build-artifact-node-${{ matrix.node-version }}
path: install-build-node-${{ matrix.node-version }}.tar
retention-days: 1
install-and-build-on-windows:
strategy:
fail-fast: false
matrix:
node-version: [16, 20]
name: Upload install and build artifact on Windows (Node ${{ matrix.node-version }})
runs-on: windows-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install dependencies
run: yarn install --immutable
- name: Build sequelize
run: yarn build
lint:
name: Lint code
runs-on: ubuntu-latest
Expand Down
16 changes: 14 additions & 2 deletions build-packages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const libDir = path.join(packageDir, 'lib');
const typesDir = path.join(packageDir, 'types');

const [sourceFiles] = await Promise.all([
// Find all .js and .ts files from /src
glob(`${sourceDir}/**/*.{mjs,cjs,js,mts,cts,ts}`, { onlyFiles: true, absolute: false }),
// Find all .js and .ts files from /src.
glob(`${convertSlashes(sourceDir)}/**/*.{mjs,cjs,js,mts,cts,ts}`, { onlyFiles: true, absolute: false }),
// Delete /lib for a full rebuild.
rmDir(libDir),
// Delete /types for a full rebuild.
Expand Down Expand Up @@ -104,3 +104,15 @@ async function copyFiles(files, fromFolder, toFolder) {
await fs.copyFile(file, to);
}));
}

// On Windows, `fileURLToPath()` returns a path with "back slashes" ("\"),
// and that's a correct behavior because Windows paths are supposed to be written in that form.
// But `fast-glob` has an issue with Windows-style paths written with "back slashes" ("\"):
// https://github.com/mrmlnc/fast-glob/issues/237
// It doesn't throw any error or provide any indication of the issue.
// It simply doesn't find any files.
// To fix that, we manually convert all "back slashes" to "forward slashes"
// when passing paths to `fast-glob` functions.
function convertSlashes(fileSystemPath) {
return fileSystemPath.replaceAll('\\', '/');
}
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
"test-db2": "cross-env DIALECT=db2 yarn test",
"test-ibmi": "cross-env DIALECT=ibmi yarn test",
"----------------------------------------- development ---------------------------------------------": "",
"build": "../../build-packages.mjs core"
"build": "node ../../build-packages.mjs core"
},
"support": true
}

0 comments on commit 808adeb

Please sign in to comment.