11import { debuglog } from 'util' ;
2+ import isUrl = require( 'is-url' ) ;
23import { parse , AtRule } from 'postcss' ;
34import {
45 parse as postCssParseValue ,
@@ -10,7 +11,6 @@ import {
1011 Punctuation ,
1112 Quoted ,
1213} from 'postcss-values-parser' ;
13- import isUrl = require( 'is-url' ) ;
1414
1515const debug = debuglog ( 'detective-postcss' ) ;
1616
@@ -26,15 +26,15 @@ function detective(src, options: detective.Options = { url: false }) {
2626 root . walkAtRules ( ( rule ) => {
2727 let file = null ;
2828 if ( isImportRule ( rule ) ) {
29- const firstNode = parseValue ( rule . params ) . first ;
29+ const firstNode = postCssParseValue ( rule . params ) . first ;
3030 file = getValueOrUrl ( firstNode ) ;
3131 if ( file ) {
3232 debug ( 'found %s of %s' , '@import' , file ) ;
3333 }
3434 }
3535
3636 if ( isValueRule ( rule ) ) {
37- const lastNode = parseValue ( rule . params ) . last ;
37+ const lastNode = postCssParseValue ( rule . params ) . last ;
3838 const prevNode = lastNode . prev ( ) ;
3939
4040 if ( prevNode && isFrom ( prevNode ) ) {
@@ -58,7 +58,7 @@ function detective(src, options: detective.Options = { url: false }) {
5858 if ( ! options . url ) return references ;
5959
6060 root . walkDecls ( ( decl ) => {
61- const { nodes } = parseValue ( decl . value ) ;
61+ const { nodes } = postCssParseValue ( decl . value ) ;
6262 const files = nodes
6363 . filter ( ( node ) => isUrlNode ( node ) )
6464 . map ( ( node ) => getValueOrUrl ( node ) ) ;
@@ -75,10 +75,6 @@ function detective(src, options: detective.Options = { url: false }) {
7575 return references ;
7676}
7777
78- function parseValue ( value : string ) {
79- return postCssParseValue ( value ) ;
80- }
81-
8278function getValueOrUrl ( node : ChildNode ) {
8379 // ['file']
8480 const ret = isUrlNode ( node ) ? getValue ( node . nodes [ 0 ] ) : getValue ( node ) ;
0 commit comments