Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #24650 from shamenchens/Bug1074166-L10NBasedir
Browse files Browse the repository at this point in the history
Bug 1074166 - Fix device type l10n missing issue, r=RickyChien
  • Loading branch information
shamenchens committed Oct 8, 2014
2 parents d71f880 + 3f685a5 commit 7ef2e1e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
8 changes: 8 additions & 0 deletions build/test/unit/mock_utils.js
Expand Up @@ -97,3 +97,11 @@ exports.getAppNameRegex = function(buildAppName) {
exports.scriptLoader = {
load: function load() {}
};

exports.dirname = function(path) {
return path.substr(0, path.lastIndexOf('/'));
};

exports.basename = function(path) {
return path.substr(path.lastIndexOf('/') + 1);
};
9 changes: 6 additions & 3 deletions build/test/unit/webapp-optimize.test.js
Expand Up @@ -61,6 +61,9 @@ suite('webapp-optimize.js', function() {
clone: function() {
return getFile(filePath);
},
get parent() {
return getFile(filePath.substr(0, filePath.lastIndexOf('/')));
},
append: function(subPath) {
filePath += '/' + subPath;
},
Expand Down Expand Up @@ -355,7 +358,6 @@ suite('webapp-optimize.js', function() {
var writeAggregatedConfig;
setup(function() {
var htmlFile = mockUtils.getFile('test-index.html');
htmlFile.parent = mockUtils.getFile('test-parent-index.html');
htmlOptimizer = new app.HTMLOptimizer({
htmlFile: htmlFile,
webapp: {
Expand Down Expand Up @@ -553,9 +555,10 @@ suite('webapp-optimize.js', function() {

test('getFileByRelativePath', function() {
isSubjectToBranding = true;
var path = '/test';
var path = '/test/foo.html';
var result = htmlOptimizer.getFileByRelativePath(path);
assert.equal(result.file.getCurrentPath(), 'build_stage/test/official');
assert.equal(result.file.getCurrentPath(),
'build_stage/test/official/foo.html');
});
});
});
2 changes: 1 addition & 1 deletion build/utils.js
Expand Up @@ -46,7 +46,7 @@ function isSubjectToBranding(path) {
* @return {bool}
*/
function isSubjectToDeviceType(path) {
return /locales[\/\\]?[a-zA-Z\/]*[\/\\]?device_type$/.test(path);
return /(locales|apps)[\/\\]?[a-zA-Z\/]*[\/\\]?device_type/.test(path);
}

/**
Expand Down
20 changes: 14 additions & 6 deletions build/webapp-optimize.js
Expand Up @@ -554,14 +554,22 @@ HTMLOptimizer.prototype.getFileByRelativePath = function(relativePath) {
return;
}
file.append(name);
if (utils.isSubjectToBranding(file.path)) {
file.append((this.config.OFFICIAL === '1') ? 'official' : 'unofficial');
}
if (utils.isSubjectToDeviceType(file.path)) {
file.append(this.config.GAIA_DEVICE_TYPE);
}
}, this);

var dirName = utils.dirname(relativePath);
var fileName = utils.basename(relativePath);

if (utils.isSubjectToBranding(dirName)) {
file = file.parent;
file.append((this.config.OFFICIAL === '1') ? 'official' : 'unofficial');
file.append(fileName);
}
if (utils.isSubjectToDeviceType(file.path)) {
file = file.parent;
file.append(this.config.GAIA_DEVICE_TYPE);
file.append(fileName);
}

try {
return {
file: file,
Expand Down

0 comments on commit 7ef2e1e

Please sign in to comment.