Skip to content

Commit

Permalink
fix: log
Browse files Browse the repository at this point in the history
  • Loading branch information
mauroreisvieira committed Mar 12, 2020
1 parent c81ad70 commit 4633ed6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
4 changes: 2 additions & 2 deletions demo/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ const settings: ISchemeSetting = {
};

generateScheme(
'Scheme Example',
'Moonlight',
'Mauro Reis Vieira <mauroreisvieira@gmail.com>',
'Scheme-Example',
'Moonlight',
settings,
'schemes'
);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Scheme Example",
"name": "Moonlight",
"author": "Mauro Reis Vieira <mauroreisvieira@gmail.com>",
"variables": {
"cursor": "#67d2ff",
Expand Down
45 changes: 28 additions & 17 deletions src/schemeGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export function generateScheme(
item.scope.forEach((i: string) => {
if (allScopes.has(i)) {
log(
chalk.bold.red('‼DUPLICATED‼') +
' - Scope [' +
chalk.bold.bgRed(' ‼ERROR‼ ') +
' - Duplicated scope [' +
chalk.bold.green(i) +
'] overwrite by: ' +
'] overwrite by ' +
chalk.yellow(item.name)
);
}
Expand All @@ -43,19 +43,30 @@ export function generateScheme(
});

fs.mkdir(dist, () => {
fs.writeFileSync(
`${dist}/${schemeName}.sublime-color-scheme`,
JSON.stringify(
{
name,
author,
variables: colors,
globals: Object.assign(defaultGlobals, ui),
rules: allRules,
},
null,
4
)
);
try {
fs.writeFileSync(
`${dist}/${schemeName}.sublime-color-scheme`,
JSON.stringify(
{
name,
author,
variables: colors,
globals: Object.assign(defaultGlobals, ui),
rules: allRules,
},
null,
4
)
);
log(
chalk.bold.bgGreen(' SUCCESS ') +
' - Scheme ' +
chalk.bold.cyan(`${schemeName}.sublime-color-scheme`) +
' created in ' +
chalk.underline.yellow(dist) + ' folder'
);
} catch (e) {
log(chalk.bold.red(e));
}
});
}

0 comments on commit 4633ed6

Please sign in to comment.