Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into cb-14242-remove-bundled-dependencies-and-n…
…ode-modules
- Loading branch information
Showing
20 changed files
with
915 additions
and
151 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 |
---|---|---|
|
@@ -10,3 +10,4 @@ console.log | |
node_modules | ||
coverage/ | ||
npm-debug.log | ||
.nyc_output/ |
This file was deleted.
Oops, something went wrong.
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
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
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,125 @@ | ||
/* | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
*/ | ||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var CordovaError = require('cordova-common').CordovaError; | ||
|
||
function BridgingHeader (bridgingHeaderPath) { | ||
this.path = bridgingHeaderPath; | ||
this.bridgingHeaders = null; | ||
if (!fs.existsSync(this.path)) { | ||
throw new CordovaError('BridgingHeader.h is not found.'); | ||
} | ||
this.bridgingHeaders = this.__parseForBridgingHeader(fs.readFileSync(this.path, 'utf8')); | ||
} | ||
|
||
BridgingHeader.prototype.addHeader = function (plugin_id, header_path) { | ||
this.bridgingHeaders.push({type: 'code', code: '#import "' + header_path + '"\n'}); | ||
}; | ||
|
||
BridgingHeader.prototype.removeHeader = function (plugin_id, header_path) { | ||
this.bridgingHeaders = this.bridgingHeaders.filter(function (line) { | ||
if (this.found) { | ||
return true; | ||
} | ||
if (line.type === 'code') { | ||
var re = new RegExp('#import\\s+"' + preg_quote(header_path) + '"(\\s*|\\s.+)(\\n|$)'); | ||
if (re.test(line.code)) { | ||
this.found = true; | ||
return false; | ||
} | ||
} | ||
return true; | ||
}, {found: false}); | ||
}; | ||
|
||
BridgingHeader.prototype.write = function () { | ||
var text = this.__stringifyForBridgingHeader(this.bridgingHeaders); | ||
fs.writeFileSync(this.path, text, 'utf8'); | ||
}; | ||
|
||
BridgingHeader.prototype.__stringifyForBridgingHeader = function (bridgingHeaders) { | ||
return bridgingHeaders.map(function (obj) { | ||
return obj.code; | ||
}).join(''); | ||
}; | ||
|
||
BridgingHeader.prototype.__parseForBridgingHeader = function (text) { | ||
var i = 0; | ||
var list = []; | ||
var type = 'code'; | ||
var start = 0; | ||
while (i < text.length) { | ||
switch (type) { | ||
case 'comment': | ||
if (i + 1 < text.length && text[i] === '*' && text[i + 1] === '/') { | ||
i += 2; | ||
list.push({type: type, code: text.slice(start, i)}); | ||
type = 'code'; | ||
start = i; | ||
} else { | ||
i += 1; | ||
} | ||
break; | ||
case 'line-comment': | ||
if (i < text.length && text[i] === '\n') { | ||
i += 1; | ||
list.push({type: type, code: text.slice(start, i)}); | ||
type = 'code'; | ||
start = i; | ||
} else { | ||
i += 1; | ||
} | ||
break; | ||
case 'code': | ||
default: | ||
if (i + 1 < text.length && text[i] === '/' && text[i + 1] === '*') { // comment | ||
if (start < i) { | ||
list.push({type: type, code: text.slice(start, i)}); | ||
} | ||
type = 'comment'; | ||
start = i; | ||
} else if (i + 1 < text.length && text[i] === '/' && text[i + 1] === '/') { // line comment | ||
if (start < i) { | ||
list.push({type: type, code: text.slice(start, i)}); | ||
} | ||
type = 'line-comment'; | ||
start = i; | ||
} else if (i < text.length && text[i] === '\n') { | ||
i += 1; | ||
list.push({type: type, code: text.slice(start, i)}); | ||
start = i; | ||
} else { | ||
i += 1; | ||
} | ||
break; | ||
} | ||
} | ||
if (start < i) { | ||
list.push({type: type, code: text.slice(start, i)}); | ||
} | ||
return list; | ||
}; | ||
|
||
function preg_quote (str, delimiter) { | ||
return (str + '').replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); | ||
} | ||
|
||
module.exports.BridgingHeader = BridgingHeader; |
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
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
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
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,8 @@ | ||
{ | ||
"spec_dir": "tests/spec", | ||
"spec_files": [ | ||
"component/**/*[sS]pec.js" | ||
], | ||
"stopSpecOnExpectationFailure": false, | ||
"random": false | ||
} |
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,63 @@ | ||
/** | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
*/ | ||
|
||
var rewire = require('rewire'); | ||
var versions = rewire('../../../bin/templates/scripts/cordova/lib/versions'); | ||
|
||
// These tests can not run on windows. | ||
if (process.platform === 'darwin') { | ||
describe('versions', function () { | ||
describe('get_tool_version method', () => { | ||
it('should not have found tool by name.', (done) => { | ||
versions.get_tool_version('unknown').catch((error) => { | ||
expect(error).toContain('is not valid tool name'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should find xcodebuild version.', (done) => { | ||
versions.get_tool_version('xcodebuild').then((version) => { | ||
expect(version).not.toBe(undefined); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should find ios-sim version.', (done) => { | ||
versions.get_tool_version('ios-sim').then((version) => { | ||
expect(version).not.toBe(undefined); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should find ios-deploy version.', (done) => { | ||
versions.get_tool_version('ios-deploy').then((version) => { | ||
expect(version).not.toBe(undefined); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should find pod version.', (done) => { | ||
versions.get_tool_version('pod').then((version) => { | ||
expect(version).not.toBe(undefined); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.