Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-organizer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-organizer - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

readme.md

5

package.json
{
"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 @@ },

62

src/bin.js
#!/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);
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc