Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(config): fix backslash regression
After the Adaptive Icon refactor, cordova-res started writing file paths with backslashes on Windows to the config file. This has now been fixed. fixes ionic-team/ionic-cli#4062
- Loading branch information
Showing
2 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import * as et from 'elementtree'; | ||
|
||
import { runResource } from '../config'; | ||
import { ResourceKey, ResourceType } from '../resources'; | ||
import { GeneratedResource, Platform } from '../platform'; | ||
|
||
describe('cordova-res', () => { | ||
|
||
describe('config', () => { | ||
|
||
describe('runResource', () => { | ||
|
||
const resource: GeneratedResource = { | ||
[ResourceKey.SRC]: '/path/to/resources/icon.png', | ||
type: ResourceType.ICON, | ||
srckey: ResourceKey.SRC, | ||
platform: Platform.ANDROID, | ||
nodeName: 'icon', | ||
nodeAttributes: [ResourceKey.SRC], | ||
}; | ||
|
||
it('should insert node for empty container', async () => { | ||
const src = 'resources/icon.png'; | ||
const container = et.Element('platform'); | ||
|
||
runResource('/path/to/config.xml', resource, container); | ||
|
||
const children = container.findall('icon'); | ||
expect(children.length).toEqual(1); | ||
expect(children[0].tag).toEqual(resource.nodeName); | ||
expect(children[0].get('src')).toEqual(src); | ||
}); | ||
|
||
it('should not change node if found in container', async () => { | ||
const src = 'resources/icon.png'; | ||
const container = et.Element('platform'); | ||
et.SubElement(container, 'icon', { src }); | ||
|
||
runResource('/path/to/config.xml', resource, container); | ||
|
||
const children = container.findall('icon'); | ||
expect(children.length).toEqual(1); | ||
expect(children[0].tag).toEqual(resource.nodeName); | ||
expect(children[0].get('src')).toEqual(src); | ||
}); | ||
|
||
it('should update node with win32 paths', async () => { | ||
const src = 'resources/icon.png'; | ||
const container = et.Element('platform'); | ||
et.SubElement(container, 'icon', { src: 'resources\\icon.png' }); | ||
|
||
runResource('/path/to/config.xml', resource, container); | ||
|
||
const children = container.findall('icon'); | ||
expect(children.length).toEqual(1); | ||
expect(children[0].tag).toEqual(resource.nodeName); | ||
expect(children[0].get('src')).toEqual(src); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters