-
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
f32e75f
commit 50726e5
Showing
9 changed files
with
303 additions
and
212 deletions.
There are no files selected for viewing
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,30 +1,36 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const { program } = require('commander'); | ||
const path = require('path'); | ||
const pkg = require('../package.json'); | ||
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 SassStyleTemplate = require('../lib/index.js'); | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
const customTemplate = path.resolve('.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')); | ||
|
||
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: 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.