From 880ab00e3c764ed21af428a5e9f57aee69d144b7 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Wed, 19 Sep 2018 10:42:05 -0700 Subject: [PATCH] fix ci path problem on Windows (#21203) Summary: fix ci path problem on Windows pass all current ci. none [GENERAL] [INTERNAL] [CI] - fix ci path problem on Windows Pull Request resolved: https://github.com/facebook/react-native/pull/21203 Differential Revision: D9943608 Pulled By: hramos fbshipit-source-id: 66e3e196a6c0015e0472851abeee32de9fef140c --- bundle/__tests__/getAssetDestPathAndroid-test.js | 6 ++++-- bundle/__tests__/getAssetDestPathIOS-test.js | 7 ++++--- link/__tests__/ios/getPlistPath.spec.js | 2 +- link/android/patches/makeSettingsPatch.js | 12 ------------ 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/bundle/__tests__/getAssetDestPathAndroid-test.js b/bundle/__tests__/getAssetDestPathAndroid-test.js index ac4e98f11..6cdbc7d18 100644 --- a/bundle/__tests__/getAssetDestPathAndroid-test.js +++ b/bundle/__tests__/getAssetDestPathAndroid-test.js @@ -14,6 +14,8 @@ jest.dontMock('../getAssetDestPathAndroid').dontMock('../assetPathUtils'); const getAssetDestPathAndroid = require('../getAssetDestPathAndroid'); +const path = require('path'); + describe('getAssetDestPathAndroid', () => { it('should use the right destination folder', () => { const asset = { @@ -45,7 +47,7 @@ describe('getAssetDestPathAndroid', () => { }; expect(getAssetDestPathAndroid(asset, 1)).toBe( - 'drawable-mdpi/app_test_icon.png', + path.normalize('drawable-mdpi/app_test_icon.png'), ); }); @@ -66,6 +68,6 @@ describe('getAssetDestPathAndroid', () => { httpServerLocation: '/assets/app/test', }; - expect(getAssetDestPathAndroid(asset, 1)).toBe('raw/app_test_video.mp4'); + expect(getAssetDestPathAndroid(asset, 1)).toBe(path.normalize('raw/app_test_video.mp4')); }); }); diff --git a/bundle/__tests__/getAssetDestPathIOS-test.js b/bundle/__tests__/getAssetDestPathIOS-test.js index 28df31411..85768396b 100644 --- a/bundle/__tests__/getAssetDestPathIOS-test.js +++ b/bundle/__tests__/getAssetDestPathIOS-test.js @@ -13,6 +13,7 @@ jest.dontMock('../getAssetDestPathIOS'); const getAssetDestPathIOS = require('../getAssetDestPathIOS'); +const path = require('path'); describe('getAssetDestPathIOS', () => { it('should build correct path', () => { @@ -22,7 +23,7 @@ describe('getAssetDestPathIOS', () => { httpServerLocation: '/assets/test', }; - expect(getAssetDestPathIOS(asset, 1)).toBe('assets/test/icon.png'); + expect(getAssetDestPathIOS(asset, 1)).toBe(path.normalize('assets/test/icon.png')); }); it('should consider scale', () => { @@ -32,7 +33,7 @@ describe('getAssetDestPathIOS', () => { httpServerLocation: '/assets/test', }; - expect(getAssetDestPathIOS(asset, 2)).toBe('assets/test/icon@2x.png'); - expect(getAssetDestPathIOS(asset, 3)).toBe('assets/test/icon@3x.png'); + expect(getAssetDestPathIOS(asset, 2)).toBe(path.normalize('assets/test/icon@2x.png')); + expect(getAssetDestPathIOS(asset, 3)).toBe(path.normalize('assets/test/icon@3x.png')); }); }); diff --git a/link/__tests__/ios/getPlistPath.spec.js b/link/__tests__/ios/getPlistPath.spec.js index ac1076792..ae2de5914 100644 --- a/link/__tests__/ios/getPlistPath.spec.js +++ b/link/__tests__/ios/getPlistPath.spec.js @@ -25,6 +25,6 @@ describe('ios::getPlistPath', () => { it('should return path without Xcode $(SRCROOT)', () => { const plistPath = getPlistPath(project, '/'); - expect(plistPath).toBe('/Basic/Info.plist'); + expect(plistPath).toBe(path.normalize('/Basic/Info.plist')); }); }); diff --git a/link/android/patches/makeSettingsPatch.js b/link/android/patches/makeSettingsPatch.js index de0e0ad6a..a6bf7ca2b 100644 --- a/link/android/patches/makeSettingsPatch.js +++ b/link/android/patches/makeSettingsPatch.js @@ -10,8 +10,6 @@ const path = require('path'); const normalizeProjectName = require('./normalizeProjectName'); -const isWin = process.platform === 'win32'; - module.exports = function makeSettingsPatch( name, androidConfig, @@ -23,16 +21,6 @@ module.exports = function makeSettingsPatch( ); const normalizedProjectName = normalizeProjectName(name); - /* - * Fix for Windows - * Backslashes is the escape character and will result in - * an invalid path in settings.gradle - * https://github.com/rnpm/rnpm/issues/113 - */ - if (isWin) { - projectDir = projectDir.replace(/\\/g, '/'); - } - return { pattern: '\n', patch: