forked from web-padawan/aybolit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve sass-render and watch scripts (web-padawan#18)
- Loading branch information
1 parent
889df60
commit b2d53ba
Showing
9 changed files
with
106 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
const commandLineArgs = require('command-line-args'); | ||
const commandLineUsage = require('command-line-usage'); | ||
const glob = require('glob'); | ||
const { sassRender } = require('../index.js'); | ||
|
||
const options = [ | ||
{ | ||
name: 'source', | ||
alias: 's', | ||
type: String, | ||
description: 'Template file to render sass into.', | ||
defaultOption: true | ||
}, | ||
{ | ||
name: 'help', | ||
alias: 'h', | ||
type: Boolean, | ||
description: 'Print this message.' | ||
} | ||
]; | ||
|
||
const { source, help } = commandLineArgs(options); | ||
|
||
function printUsage() { | ||
const sections = [ | ||
{ | ||
header: 'sass-render', | ||
content: 'Render sass into css tagged template literal' | ||
}, | ||
{ | ||
header: 'Options', | ||
optionList: options | ||
} | ||
]; | ||
console.log(commandLineUsage(sections)); | ||
} | ||
|
||
if (help) { | ||
printUsage(); | ||
process.exit(0); | ||
} | ||
|
||
if (!source) { | ||
console.error('Must provide a source!'); | ||
printUsage(); | ||
process.exit(-1); | ||
} | ||
|
||
glob(source, (err, files) => { | ||
files | ||
.filter(file => !path.basename(file).startsWith('_')) | ||
.forEach(file => { | ||
sassRender(file).catch(error => { | ||
console.error(error); | ||
process.exit(-1); | ||
}); | ||
}); | ||
}); |
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,17 @@ | ||
{ | ||
"name": "@aybolit/sass-render", | ||
"private": true, | ||
"version": "0.1.0", | ||
"author": "Serhii Kulykov <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"command-line-args": "^5.0.2", | ||
"command-line-usage": "^5.0.5", | ||
"glob": "^7.1.3", | ||
"node-sass-import": "^2.0.1", | ||
"sass": "^1.17.3" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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