@@ -2,12 +2,12 @@ import {
22 COLLECTION_DAPP ,
33 DEPLOY_DEFAULT_IGNORE ,
44 DEPLOY_DEFAULT_SOURCE ,
5- files as listFiles ,
6- hasArgs
5+ hasArgs ,
6+ files as listFiles
77} from '@junobuild/cli-tools' ;
88import { deleteManyAssets , type Asset } from '@junobuild/core' ;
9- import { minimatch } from 'minimatch' ;
109import { green , red , yellow } from 'kleur' ;
10+ import { minimatch } from 'minimatch' ;
1111import { join } from 'node:path' ;
1212import ora from 'ora' ;
1313import { noJunoConfig } from '../../configs/juno.config' ;
@@ -19,23 +19,34 @@ import {listAssets} from './_deploy/deploy.list.services';
1919 * Converts an absolute file path to its fullPath form.
2020 * e.g. "/path/to/build/index.html" -> "/index.html"
2121 */
22- const toFullPath = ( file : string , sourceAbsolutePath : string ) : string =>
23- file . replace ( sourceAbsolutePath , '' ) . replace ( / \\ / g, '/' ) ;
22+ const toFullPath = ( {
23+ file,
24+ sourceAbsolutePath
25+ } : {
26+ file : string ;
27+ sourceAbsolutePath : string ;
28+ } ) : string => file . replace ( sourceAbsolutePath , '' ) . replace ( / \\ / g, '/' ) ;
2429
2530/**
2631 * Returns true if the file should be excluded based on the ignore patterns.
2732 */
28- const isIgnored = ( file : string , ignore : string [ ] ) : boolean =>
33+ const isIgnored = ( { file, ignore } : { file : string ; ignore : string [ ] } ) : boolean =>
2934 ignore . some ( ( pattern ) => minimatch ( file , pattern , { matchBase : true } ) ) ;
3035
3136/**
3237 * Scans the local source directory and returns a Set of fullPaths that are present.
3338 * Throws if the directory cannot be read.
3439 */
35- const buildLocalPaths = ( sourceAbsolutePath : string , ignore : string [ ] ) : Set < string > => {
40+ const buildLocalPaths = ( {
41+ sourceAbsolutePath,
42+ ignore
43+ } : {
44+ sourceAbsolutePath : string ;
45+ ignore : string [ ] ;
46+ } ) : Set < string > => {
3647 const allFiles = listFiles ( sourceAbsolutePath ) ;
37- const filteredFiles = allFiles . filter ( ( file ) => ! isIgnored ( file , ignore ) ) ;
38- return new Set ( filteredFiles . map ( ( file ) => toFullPath ( file , sourceAbsolutePath ) ) ) ;
48+ const filteredFiles = allFiles . filter ( ( file ) => ! isIgnored ( { file, ignore} ) ) ;
49+ return new Set ( filteredFiles . map ( ( file ) => toFullPath ( { file, sourceAbsolutePath} ) ) ) ;
3950} ;
4051
4152export const prune = async ( args ?: string [ ] ) => {
@@ -100,7 +111,7 @@ const scanLocalFiles = ({
100111 source : string ;
101112} ) : Set < string > => {
102113 try {
103- const paths = buildLocalPaths ( sourceAbsolutePath , ignore ) ;
114+ const paths = buildLocalPaths ( { sourceAbsolutePath, ignore} ) ;
104115 scanSpinner . stop ( ) ;
105116 return paths ;
106117 } catch ( err : unknown ) {
0 commit comments