Skip to content

Commit 2f89486

Browse files
authored
fix(windows): Fix path issues on Windows (#170)
* ci(windows): Runs tests on Windows too * fix(windows): Fix path issues on Windows
1 parent 7e647c3 commit 2f89486

5 files changed

Lines changed: 27 additions & 8 deletions

File tree

.gitattributes

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
*.pbxproj eol=lf

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060

6161
strategy:
6262
matrix:
63-
os: [ubuntu-latest, macos-26]
63+
os: [windows-latest, ubuntu-latest, macos-26]
6464
# The "--test-coverage-exclude" flag is supported in v22.5.0 and later.
6565
# By default, all matching test files are excluded from the coverage report.
6666
# Only Node.js 22.x requires explicitly declaring test file exclusions.
@@ -100,6 +100,7 @@ jobs:
100100
NODE_OPTIONS: ${{ matrix.node.options }}
101101

102102
- name: Check for uncommitted changes
103+
if: ${{ ! startsWith(matrix.os, 'windows') }}
103104
run: |
104105
if ! git diff --exit-code; then
105106
echo ""

lib/pbxFile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function defaultPath (fileRef, filePath) {
165165
}
166166

167167
if (defaultPath) {
168-
return path.join(defaultPath, path.basename(filePath));
168+
return path.posix.join(defaultPath, path.basename(filePath));
169169
}
170170

171171
return filePath;

lib/pbxProject.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function PBXProject (filename) {
3939
util.inherits(PBXProject, EventEmitter);
4040

4141
PBXProject.prototype.parse = function (cb) {
42-
const worker = fork(path.join(__dirname, '/parseJob.js'), [this.filepath]);
42+
const worker = fork(path.join(__dirname, 'parseJob.js'), [this.filepath]);
4343

4444
worker.on('message', function (msg) {
4545
if (msg.name === 'SyntaxError' || msg.code) {
@@ -1392,7 +1392,7 @@ PBXProject.prototype.addTarget = function (name, type, subfolder, bundleId) {
13921392
// Setup uuid and name of new target
13931393
const targetUuid = this.generateUuid();
13941394
const targetType = type;
1395-
const targetSubfolder = subfolder || name;
1395+
const targetSubfolder = (subfolder || name).replace(/\\/g, '/');
13961396
const targetName = name.trim();
13971397
const targetBundleId = bundleId;
13981398

@@ -1418,7 +1418,7 @@ PBXProject.prototype.addTarget = function (name, type, subfolder, bundleId) {
14181418
isa: 'XCBuildConfiguration',
14191419
buildSettings: {
14201420
GCC_PREPROCESSOR_DEFINITIONS: ['"DEBUG=1"', '"$(inherited)"'],
1421-
INFOPLIST_FILE: '"' + path.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'),
1421+
INFOPLIST_FILE: '"' + path.posix.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'),
14221422
LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"',
14231423
PRODUCT_NAME: '"' + targetName + '"',
14241424
SKIP_INSTALL: 'YES'
@@ -1428,7 +1428,7 @@ PBXProject.prototype.addTarget = function (name, type, subfolder, bundleId) {
14281428
name: 'Release',
14291429
isa: 'XCBuildConfiguration',
14301430
buildSettings: {
1431-
INFOPLIST_FILE: '"' + path.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'),
1431+
INFOPLIST_FILE: '"' + path.posix.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'),
14321432
LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"',
14331433
PRODUCT_NAME: '"' + targetName + '"',
14341434
SKIP_INSTALL: 'YES'

test/dataModelDocument.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const path = require('node:path');
2626
const PBXProject = require('../lib/pbxProject');
2727
const PBXFile = require('../lib/pbxFile');
2828
const proj = new PBXProject('.');
29-
const singleDataModelFilePath = path.join(__dirname, '/fixtures/single-data-model.xcdatamodeld');
30-
const multipleDataModelFilePath = path.join(__dirname, '/fixtures/multiple-data-model.xcdatamodeld');
29+
const singleDataModelFilePath = path.join(__dirname, 'fixtures', 'single-data-model.xcdatamodeld');
30+
const multipleDataModelFilePath = path.join(__dirname, 'fixtures', 'multiple-data-model.xcdatamodeld');
3131

3232
function cleanHash () {
3333
return JSON.parse(fullProjectStr);

0 commit comments

Comments
 (0)