summaryrefslogtreecommitdiff
path: root/node_modules/postcss-cli/lib
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2025-11-24 20:54:57 +0100
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2025-11-24 20:57:48 +0100
commitb1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c (patch)
tree49d360fd6cbc6a2754efe93524ac47ff0fbe0f7d /node_modules/postcss-cli/lib
Docs
Diffstat (limited to 'node_modules/postcss-cli/lib')
-rw-r--r--node_modules/postcss-cli/lib/DependencyGraph.js30
-rw-r--r--node_modules/postcss-cli/lib/args.js115
-rw-r--r--node_modules/postcss-cli/lib/getMapfile.js7
3 files changed, 152 insertions, 0 deletions
diff --git a/node_modules/postcss-cli/lib/DependencyGraph.js b/node_modules/postcss-cli/lib/DependencyGraph.js
new file mode 100644
index 0000000..efb7ac3
--- /dev/null
+++ b/node_modules/postcss-cli/lib/DependencyGraph.js
@@ -0,0 +1,30 @@
+import path from 'path'
+import { DepGraph } from 'dependency-graph'
+
+export default function createDependencyGraph() {
+ const graph = new DepGraph()
+ return {
+ add(message) {
+ message.parent = path.resolve(message.parent)
+ graph.addNode(message.parent)
+
+ if (message.type === 'dir-dependency') {
+ message.dir = path.resolve(message.dir)
+ graph.addNode(message.dir)
+ graph.addDependency(message.parent, message.dir)
+ } else {
+ message.file = path.resolve(message.file)
+ graph.addNode(message.file)
+ graph.addDependency(message.parent, message.file)
+ }
+
+ return message
+ },
+ dependantsOf(node) {
+ node = path.resolve(node)
+
+ if (graph.hasNode(node)) return graph.dependantsOf(node)
+ return []
+ },
+ }
+}
diff --git a/node_modules/postcss-cli/lib/args.js b/node_modules/postcss-cli/lib/args.js
new file mode 100644
index 0000000..35f0e83
--- /dev/null
+++ b/node_modules/postcss-cli/lib/args.js
@@ -0,0 +1,115 @@
+import yargs from 'yargs'
+
+const { argv } = yargs(process.argv.slice(2))
+ .usage(
+ `Usage:
+ $0 [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w]
+ $0 <input.css>... [OPTIONS] --dir <output-directory> [--watch|-w]
+ $0 <input-directory> [OPTIONS] --dir <output-directory> [--watch|-w]
+ $0 <input-glob-pattern> [OPTIONS] --dir <output-directory> [--watch|-w]
+ $0 <input.css>... [OPTIONS] --replace`
+ )
+ .group(
+ ['o', 'd', 'r', 'map', 'no-map', 'watch', 'verbose', 'env'],
+ 'Basic options:'
+ )
+ .option('o', {
+ alias: 'output',
+ desc: 'Output file',
+ type: 'string',
+ conflicts: ['dir', 'replace'],
+ })
+ .option('d', {
+ alias: 'dir',
+ desc: 'Output directory',
+ type: 'string',
+ conflicts: ['output', 'replace'],
+ })
+ .option('r', {
+ alias: 'replace',
+ desc: 'Replace (overwrite) the input file',
+ type: 'boolean',
+ conflicts: ['output', 'dir'],
+ })
+ .alias('m', 'map')
+ .describe('map', 'Create an external sourcemap')
+ .describe('no-map', 'Disable the default inline sourcemaps')
+ .option('w', {
+ alias: 'watch',
+ desc: 'Watch files for changes and recompile as needed',
+ type: 'boolean',
+ conflicts: 'replace',
+ })
+ .option('verbose', {
+ desc: 'Be verbose',
+ type: 'boolean',
+ })
+ .option('env', {
+ desc: 'A shortcut for setting NODE_ENV',
+ type: 'string',
+ })
+ .group(
+ ['u', 'parser', 'stringifier', 'syntax'],
+ 'Options for use without a config file:'
+ )
+ .option('u', {
+ alias: 'use',
+ desc: 'List of postcss plugins to use',
+ type: 'array',
+ })
+ .option('parser', {
+ desc: 'Custom postcss parser',
+ type: 'string',
+ })
+ .option('stringifier', {
+ desc: 'Custom postcss stringifier',
+ type: 'string',
+ })
+ .option('syntax', {
+ desc: 'Custom postcss syntax',
+ type: 'string',
+ })
+ .group(['ext', 'base'], 'Options for use with --dir:')
+ .option('ext', {
+ desc: 'Override the output file extension; for use with --dir',
+ type: 'string',
+ implies: 'dir',
+ })
+ .option('base', {
+ desc: 'Mirror the directory structure relative to this path in the output directory, for use with --dir',
+ type: 'string',
+ implies: 'dir',
+ })
+ .group(['include-dotfiles', 'poll', 'config'], 'Advanced options:')
+ .option('include-dotfiles', {
+ desc: 'Enable glob to match files/dirs that begin with "."',
+ type: 'boolean',
+ })
+ .option('poll', {
+ desc: 'Use polling for file watching. Can optionally pass polling interval; default 100 ms',
+ implies: 'watch',
+ })
+ .option('config', {
+ desc: 'Set a custom directory to look for a config file',
+ type: 'string',
+ })
+ .alias('h', 'help')
+ .example('$0 input.css -o output.css', 'Basic usage')
+ .example('$0 src/**/*.css --base src --dir build', 'Glob Pattern & output')
+ .example(
+ 'cat input.css | $0 -u autoprefixer > output.css',
+ 'Piping input & output'
+ )
+ .epilog(
+ `If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout.
+
+If there are multiple input files, the --dir or --replace option must be passed.
+
+Input files may contain globs (e.g. src/**/*.css). If you pass an input directory, it will process all files in the directory and any subdirectories, respecting the glob pattern.
+
+For more details, please see https://github.com/postcss/postcss-cli`
+ )
+
+if (argv.ext && argv.ext.indexOf('.') !== 0) argv.ext = `.${argv.ext}`
+
+export default argv
diff --git a/node_modules/postcss-cli/lib/getMapfile.js b/node_modules/postcss-cli/lib/getMapfile.js
new file mode 100644
index 0000000..e4d0c93
--- /dev/null
+++ b/node_modules/postcss-cli/lib/getMapfile.js
@@ -0,0 +1,7 @@
+import path from 'path'
+export default function getMapfile(options) {
+ if (options.map && typeof options.map.annotation === 'string') {
+ return `${path.dirname(options.to)}/${options.map.annotation}`
+ }
+ return `${options.to}.map`
+}