-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from magento-frontend/MAGETWO-55345
MAGETWO-55345 Grunt uses actual theme's list
- Loading branch information
Showing
8 changed files
with
98 additions
and
7 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
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
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,83 @@ | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var defaultConfig = {}, | ||
|
||
/** | ||
* Generates full path to file. | ||
* | ||
* @param {String} path - relative path to file. | ||
* | ||
* @returns {String} Full path to file | ||
*/ | ||
getFullPath = function (path) { | ||
return process.cwd() + '/' + path; | ||
}, | ||
|
||
/** | ||
* Returns file. | ||
* | ||
* @param {String} path - relative path to file. | ||
* | ||
* @returns {Object|Null} File or NULL | ||
*/ | ||
getFile = function (path) { | ||
try { | ||
return require(getFullPath(path)); | ||
} catch (error) { | ||
return null; | ||
} | ||
}, | ||
|
||
/** | ||
* Immediately invoked function. | ||
* Loads user config file. | ||
*/ | ||
userConfig = (function () { | ||
try { | ||
return require(process.cwd() + '/grunt-config'); | ||
} catch (error) { | ||
return null; | ||
} | ||
})(); | ||
|
||
module.exports = { | ||
|
||
/** | ||
* Loads file. | ||
* Load priority: | ||
* From user config; | ||
* From default config with ".loc" suffix ; | ||
* From default config; | ||
* | ||
* @param {String} alias | ||
* | ||
* @returns {Object} themes file or error | ||
*/ | ||
get: function (alias) { | ||
var tmp; | ||
|
||
if (userConfig && userConfig[alias]) { | ||
return require(getFullPath(userConfig[alias])); | ||
} else if (tmp = getFile(defaultConfig[alias] + '.loc') || getFile(defaultConfig[alias])) { | ||
return tmp; | ||
} else { | ||
throw new Error('Cannot find file. Alias "' + alias + '" not set. ' + | ||
'Use "filesRouter.set" method to set it.').stack; | ||
} | ||
}, | ||
|
||
/** | ||
* Sets file alias. | ||
* | ||
* @param {String} alias | ||
* @param {String} path | ||
*/ | ||
set: function (alias, path) { | ||
defaultConfig[alias] = path; | ||
} | ||
}; |
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,3 @@ | ||
{ | ||
"themes": "dev/tools/grunt/configs/local-themes" | ||
} |