@anolilab/stylelint-config
Version:
Stylelint shareable config for the Anolilab stylesheet guide.
19 lines (16 loc) • 1.59 kB
JavaScript
var f=Object.defineProperty;var r=(e,o)=>f(e,"name",{value:o,configurable:!0});import{existsSync as a}from"node:fs";import{readFile as g,writeFile as c}from"node:fs/promises";import{join as l}from"node:path";import{exit as s}from"node:process";var d=Object.defineProperty,y=r((e,o)=>d(e,"name",{value:o,configurable:!0}),"i");const t=".stylelintrc",u=y(async(e,o)=>{for(const i of[t,`${t}.js`,`${t}.cjs`,`${t}.json`,`${t}.yaml`,`${t}.yml`,"stylelint.config.js","stylelint.config.cjs"])if(a(l(e,i))){console.warn('⚠️ .stylelintrc.js already exists; Make sure that it includes the following for @anolilab/stylelint-config to work as it should: { "extends": ["@anolilab/stylelint-config"] }.');return}const n=l(e,".stylelintrc.js");await c(n,`${o?"export default":"module.exports ="} {
"extends": [
"@anolilab/stylelint-config",
]
};
`,"utf-8")},"writeStylelintRc"),m=y(async e=>{const o=l(e,".stylelintignore");a(o)||await c(o,`package.json
package-lock.json
yarn.lock
pnpm-lock.yaml
build/**
node_modules/**
.next/**
dist/**
`,"utf-8")},"writeStylelintIgnore");(async()=>{const e=process.cwd(),o=l(e,"package.json");a(o)||(console.error("😬 No package.json found in the current directory. You need to run this command in a directory with a package.json file."),s(1));const n=JSON.parse(await g(o,"utf-8"));console.log("Configuring @anolilab/stylelint-config",e,`
`);try{await u(e,n?.type==="module"),await m(e),console.log("😎 Everything went well, have fun!"),s(0)}catch(i){console.log("😬 something went wrong:"),console.error(i),s(1)}})();