Navigation Menu

Skip to content

Commit

Permalink
Support specifying iOS shared libraries (#172)
Browse files Browse the repository at this point in the history
* Update mock-fs to support Node v6

* Normalize iOS shared library names

This relates to #122, but the bulk of the work must be done in npm-plugin-link.
  • Loading branch information
appden authored and grabbou committed Jun 9, 2016
1 parent 7ef2ccb commit bdb41b4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"babel-eslint": "^4.1.5",
"eslint": "^1.9.0",
"mock-fs": "^3.5.0",
"mock-fs": "^3.9.0",
"mock-require": "^1.2.1",
"rewire": "^2.5.1",
"jest-cli": "^0.9.0-fb2"
Expand Down
14 changes: 14 additions & 0 deletions src/config/ios/index.js
@@ -1,6 +1,19 @@
const path = require('path');
const findProject = require('./findProject');

/**
* For libraries specified without an extension, add '.tbd' for those that
* start with 'lib' and '.framework' to the rest.
*/
const mapSharedLibaries = (libraries) => {
return libraries.map(name => {
if (path.extname(name)) {
return name;
}
return name + (name.indexOf('lib') === 0 ? '.tbd' : '.framework');
});
};

/**
* Returns project config by analyzing given folder and applying some user defaults
* when constructing final object
Expand All @@ -24,6 +37,7 @@ exports.projectConfig = function projectConfigIOS(folder, userConfig) {
projectPath: projectPath,
projectName: path.basename(projectPath),
libraryFolder: userConfig.libraryFolder || 'Libraries',
sharedLibraries: mapSharedLibaries(userConfig.sharedLibraries || []),
plist: userConfig.plist || [],
};
};
Expand Down
10 changes: 10 additions & 0 deletions test/ios/getProjectConfig.spec.js
Expand Up @@ -22,5 +22,15 @@ describe('ios::getProjectConfig', () => {
expect(getProjectConfig(folder, userConfig)).toBe(null);
});

it('should return normalized shared library names', () => {
const projectConfig = getProjectConfig('testDir/nested', {
sharedLibraries: ['libc++', 'libz.tbd', 'HealthKit', 'HomeKit.framework'],
});

expect(projectConfig.sharedLibraries).toEqual(
['libc++.tbd', 'libz.tbd', 'HealthKit.framework', 'HomeKit.framework']
);
});

afterEach(mockFs.restore);
});

0 comments on commit bdb41b4

Please sign in to comment.