Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update style-dictionary clean config path #454

Merged
merged 1 commit into from
Oct 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions bin/style-dictionary
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ function collect(val, arr) {
return arr;
}

function getConfigPath(options) {
var configPath = options.config;

if(!configPath) {
if(fs.existsSync('./config.json')) {
configPath = './config.json';
}
else if(fs.existsSync('./config.js')) {
configPath = './config.js';
}
else {
console.error('Build failed; unable to find config file.');
process.exit(1);
}
}

return configPath;
}

program
.version(pkg.version)
.description(pkg.description)
Expand Down Expand Up @@ -59,20 +78,7 @@ program.on('command:*', function () {

function styleDictionaryBuild(options) {
options = options || {};
var configPath = options.config;

if(!configPath) {
if(fs.existsSync('./config.json')) {
configPath = './config.json';
}
else if(fs.existsSync('./config.js')) {
configPath = './config.js';
}
else {
console.error('Build failed; unable to find config file.');
process.exit(1);
}
}
var configPath = getConfigPath(options);

// Create a style dictionary object with the config
var styleDictionary = StyleDictionary.extend( configPath );
Expand All @@ -88,7 +94,7 @@ function styleDictionaryBuild(options) {

function styleDictionaryClean(options) {
options = options || {};
var configPath = options.config ? options.config : './config.json';
var configPath = getConfigPath(options);

// Create a style dictionary object with the config
var styleDictionary = StyleDictionary.extend( configPath );
Expand Down