css-organizer
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "css-organizer", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"bin": { | ||
@@ -8,6 +8,7 @@ "organize": "./src/bin.js" | ||
"dependencies": { | ||
"chalk": "^2.4.1", | ||
"fast-glob": "^2.2.3", | ||
"minimist": "^1.2.0", | ||
"postcss": "^7.0.5", | ||
"postcss-organizer": "0.0.2", | ||
"postcss-organizer": "0.0.3", | ||
"seekout": "^1.0.2" | ||
@@ -14,0 +15,0 @@ }, |
#!/usr/bin/env node | ||
'use strict'; | ||
/* eslint-disable global-require */ | ||
const { name, version } = require('../package'); | ||
process.title = name; | ||
const CONFIG = '.cssorgrc.js'; | ||
const USAGE = ` | ||
@@ -11,4 +14,10 @@ $ organize <file,glob> [options] | ||
Options: | ||
-h, --help print usage | ||
-v, --version print version | ||
-h, --help Print usage | ||
-p, --presetf NAME Preset to use. Available presets: default | ||
-v, --version Print version | ||
Examples: | ||
Format css files in project | ||
$ organize --preset default src/**/*.css | ||
`; | ||
@@ -20,2 +29,3 @@ | ||
help: 'h', | ||
preset: 'p', | ||
version: 'v', | ||
@@ -40,20 +50,44 @@ }, | ||
const postcss = require('postcss'); | ||
const postcssOrganizerPlugin = require('postcss-organizer'); | ||
let config = null; | ||
if (argv.preset) { | ||
const { presets } = postcssOrganizerPlugin; | ||
if (!presets.includes(argv.preset)) { | ||
console.error(`Unknown preset "${argv.preset}". Available presets are ${presets.join(', ')}.`); | ||
process.exit(1); | ||
} | ||
config = { preset: argv.preset }; | ||
} else { | ||
const seekout = require('seekout'); | ||
const cfgpath = seekout(CONFIG); | ||
config = cfgpath ? require(cfgpath) : null; | ||
} | ||
const fg = require('fast-glob'); | ||
const fs = require('fs'); | ||
const util = require('util'); | ||
const formatError = require('./format-error'); | ||
const pcss = postcss([postcssOrganizerPlugin(config)]); | ||
const readFile = util.promisify(fs.readFile); | ||
const writeFile = util.promisify(fs.writeFile); | ||
const seekout = require('seekout'); | ||
const configpath = seekout('.cssorganizerrc.js'); | ||
const config = configpath ? require(configpath) : null; | ||
const postcss = require('postcss'); | ||
const postcssOrganizerPlugin = require('postcss-organizer'); | ||
const css = postcss([postcssOrganizerPlugin(config)]); | ||
const fg = require('fast-glob'); | ||
const stream = fg.stream(argv._, { absolute: true }); | ||
stream.on('data', abspath => readFile(abspath, 'utf8') | ||
.then(data => css.process(data, { from: abspath, to: abspath })) | ||
.then(result => writeFile(abspath, result.css, 'utf8'))); | ||
stream | ||
.on('data', abspath => readFile(abspath, 'utf8') | ||
.then(data => pcss.process(data, { from: abspath, to: abspath })) | ||
.then(result => writeFile(abspath, result.css, 'utf8')) | ||
.catch(error => { | ||
console.log(formatError(error)); | ||
process.exit(1); | ||
})) | ||
.once('error', error => { | ||
console.log(formatError(error)); | ||
process.exit(1); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
122070
7
86
1
23
6
+ Addedchalk@^2.4.1
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedpostcss-organizer@0.0.3(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removedpostcss-organizer@0.0.2(transitive)
Updatedpostcss-organizer@0.0.3