-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Config: Add support for a config file (#9)
- Adds the ability to store audit arguments in a configuration file named css-audit.config.js in the root of the project, fixes #8 - Supports multiple property-values audits from the config Co-authored-by: Kelly Dwan <ryelle@users.noreply.github.com>
- Loading branch information
Showing
16 changed files
with
3,048 additions
and
1,553 deletions.
There are no files selected for viewing
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 @@ | ||
14 |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
format: 'html', | ||
all: true, | ||
filename: 'wp-admin', | ||
audits: [ [ 'property-values', 'font-size' ] ], | ||
}; |
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,38 @@ | ||
/** | ||
* Node dependencies | ||
*/ | ||
const fs = require( 'fs' ); | ||
const path = require( 'path' ); | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
const { runAudits } = require( './src/run' ); | ||
const { getArg, getFileArgsFromCLI, getHelp } = require( './src/utils/cli' ); | ||
|
||
const input = getFileArgsFromCLI(); | ||
|
||
if ( getArg( '--help', true ) || ! input.length ) { | ||
console.log( getHelp() ); | ||
process.exit( 0 ); | ||
} | ||
|
||
const cssFiles = []; | ||
input.forEach( ( file ) => { | ||
const filePath = path.resolve( process.env.INIT_CWD, file ); | ||
const stats = fs.statSync( filePath ); | ||
if ( stats.isDirectory() ) { | ||
return; | ||
} | ||
if ( file.match( /min\.css$/ ) ) { | ||
return; | ||
} | ||
cssFiles.push( { | ||
name: file, | ||
content: String( fs.readFileSync( filePath ) ), | ||
} ); | ||
} ); | ||
|
||
const result = runAudits( cssFiles ); | ||
|
||
console.log( result ); |
Oops, something went wrong.