-
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.
- Loading branch information
1 parent
7a6ce7a
commit 2c44201
Showing
10 changed files
with
274 additions
and
169 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,35 +1,36 @@ | ||
#!/usr/bin/env node | ||
|
||
import fs from 'fs'; | ||
import { program } from 'commander'; | ||
import { SassStyleTemplate } from '../lib/index.js'; | ||
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import {fileURLToPath} from 'node:url'; | ||
import {program} from 'commander'; | ||
import {SassStyleTemplate} from '../lib/index.js'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
const pkgPath = path.resolve(__dirname, '../package.json'); | ||
const customTemplate = path.resolve(__dirname, '../.sass-template.tmpl'); | ||
const customTemplatePath = path.resolve(process.cwd(), '.sass-template.tmpl'); | ||
const tplTemplatePath = path.resolve(__dirname, '../tpls/sass-template.tmpl'); | ||
|
||
const pkgPath = path.resolve(__dirname, '../package.json'); | ||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); | ||
console.log('=>:', pkg.version); | ||
|
||
program | ||
.version(pkg.version, '-v, --version', 'show version number') | ||
.option('-s, --marker-start <string>', 'start replace position') | ||
.option('-e, --marker-end <string>', 'end replace position') | ||
.option('-g, --custom-glob <string>', 'string pattern to be matched') | ||
.option('-f, --css-file', 'generate css file instead of using template') | ||
.option('-c, --css-file', 'generate a CSS file instead of JS or TS') | ||
.option('-wo, --wo-suffix', 'without suffix string `-styles`') | ||
.option('-j, --js-file <string>', 'file extension') | ||
.option('-d, --destination <string>', 'location of the output file'); | ||
|
||
program.parse(process.argv); | ||
|
||
const template = fs.existsSync(customTemplate) | ||
? fs.readFileSync(customTemplate, 'utf8') | ||
: undefined; | ||
const template = fs.existsSync(customTemplatePath) | ||
? fs.readFileSync(customTemplatePath, 'utf8') | ||
: fs.readFileSync(tplTemplatePath, 'utf8'); | ||
|
||
const config = Object.assign({}, program.opts(), { template }); | ||
const config = Object.assign({}, program.opts(), {template}); | ||
|
||
new SassStyleTemplate(config); |
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,10 @@ | ||
import globals from 'globals'; | ||
import pluginJs from '@eslint/js'; | ||
import eslintConfigPrettier from 'eslint-config-prettier'; | ||
|
||
/** @type {import('eslint').Linter.Config[]} */ | ||
export default [ | ||
{languageOptions: {globals: globals.node}}, | ||
pluginJs.configs.recommended, | ||
eslintConfigPrettier, | ||
]; |
Oops, something went wrong.