CB-5889 Make update script find project name instead of using "null" for CordovaLib

This commit is contained in:
Andrew Grieve 2014-01-24 10:40:09 -05:00
parent f28738fe6d
commit 06660383e1

View File

@ -202,18 +202,29 @@ exports.createProject = function(project_path, package_name, project_name, proje
// Attribute removed in Cordova 4.4 (CB-5447). // Attribute removed in Cordova 4.4 (CB-5447).
function removeDebuggableFromManifest(projectPath) { function removeDebuggableFromManifest(projectPath) {
var manifestPath = path.join(projectPath, 'AndroidManifest.xml'); var manifestPath = path.join(projectPath, 'AndroidManifest.xml');
shell.sed('-i', /\s*android:debuggable="true"/, '', manifestPath); shell.sed('-i', /\s*android:debuggable="true"/, '', manifestPath);
} }
function extractProjectNameFromManifest(projectPath) {
var manifestPath = path.join(projectPath, 'AndroidManifest.xml');
var manifestData = fs.readFileSync(manifestPath, 'utf8');
var m = /<activity[\s\S]*?android:name\s*=\s*"(.*?)"/i.exec(manifestData);
if (!m) {
throw new Error('Could not find activity name in ' + manifestPath);
}
return m[1];
}
// Returns a promise. // Returns a promise.
exports.updateProject = function(projectPath) { exports.updateProject = function(projectPath) {
var version = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim(); var version = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
// Check that requirements are met and proper targets are installed // Check that requirements are met and proper targets are installed
return check_reqs.run() return check_reqs.run()
.then(function() { .then(function() {
var projectName = extractProjectNameFromManifest(projectPath);
var target_api = check_reqs.get_target(); var target_api = check_reqs.get_target();
copyJsAndLibrary(projectPath, false, null); copyJsAndLibrary(projectPath, false, projectName);
copyScripts(projectPath); copyScripts(projectPath);
copyAntRules(projectPath); copyAntRules(projectPath);
removeDebuggableFromManifest(projectPath); removeDebuggableFromManifest(projectPath);