Skip to content

Commit

Permalink
feat: pretty log
Browse files Browse the repository at this point in the history
  • Loading branch information
TMaize committed Jun 21, 2023
1 parent 68910c4 commit ae6ed67
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
15 changes: 10 additions & 5 deletions bin/svg-css-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ function getStringArg(name) {
return process.argv[idx + 1]
}

build({
input: getStringArg('input'),
output: getStringArg('output'),
class: getStringArg('class')
})
try {
build({
input: getStringArg('input'),
output: getStringArg('output'),
class: getStringArg('class')
})
} catch (err) {
console.error(err.message)
process.exit(1)
}
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = function build(options) {
for (let i = 0; i < files.length; i++) {
const file = files[i]
const name = path.basename(file).replace(/\.svg$/i, '')
console.log('build', file)
console.log(' build:', file)

let svg = fs.readFileSync(file, 'utf-8')
const colorful = isColorful(svg)
Expand All @@ -55,10 +55,10 @@ module.exports = function build(options) {
if (colorful) {
content += `\n.${options.class}-${name} {\n background-image: url(${svg});\n}\n`
} else {
content += `\n.${options.class}-${name} {\n --data: url(${svg});\n mask-image: var(--data);\n -webkit-mask-image: var(--data); background-color: currentColor;\n}\n`
content += `\n.${options.class}-${name} {\n --data: url(${svg});\n mask-image: var(--data);\n -webkit-mask-image: var(--data);\n background-color: currentColor;\n}\n`
}
}

console.log('output', options.output)
console.log('output:', options.output)
fs.writeFileSync(options.output, content)
}
3 changes: 2 additions & 1 deletion test/icon.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<style>
body {
margin: 0;
padding: 10px;
display: flex;
flex-flow: row wrap;
}
Expand All @@ -24,6 +25,8 @@
position: relative;
position: relative;
color: #2b96a4;
margin-left: -1px;
margin-top: -1px;
}

body > div > span::after {
Expand Down

0 comments on commit ae6ed67

Please sign in to comment.