From 0de3bee417ea7b9137cb872980626edc6a03ab63 Mon Sep 17 00:00:00 2001 From: Stefan Zerkalica Date: Mon, 21 Oct 2024 12:37:47 +0300 Subject: [PATCH] $mol_file improve copy api 3 --- build/build.node.ts | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/build/build.node.ts b/build/build.node.ts index e0165b82a5..446b638394 100644 --- a/build/build.node.ts +++ b/build/build.node.ts @@ -1404,14 +1404,23 @@ namespace $ { const root = this.root() const pack = $mol_file.absolute( path ) - var sources = this.sourcesAll( [ path , exclude ] ) - .filter( src => /meta.tree$/.test( src.ext() ) ) + const sources = this.sourcesAll( [ path , exclude ] ) + .filter( src => /meta.tree$/.test( src.ext() ) ) const targets : $mol_file[] = [] - sources.forEach( source => { - const tree = this.$.$mol_tree2_from_string( source.text() , source.path() ) - const pushFile = (file:$mol_file) => { + for (const source of sources) { + + const addFilesRecursive = (file:$mol_file) =>{ + + if ( ! file.exists() ) return + + if( file.type() === 'dir') { + for (const sub of file.sub()) { + addFilesRecursive(sub) + } + return + } const start = Date.now() const target = file.clone(pack.resolve( `-/${ file.relate( root ) }` ).path()) @@ -1421,24 +1430,13 @@ namespace $ { this.logBundle( target , Date.now() - start ) } - const addFilesRecursive = (file:$mol_file) =>{ - - if ( ! file.exists() ) return - if( file.type() === 'dir') { - file.sub().forEach(sub => { - addFilesRecursive(sub) - }) - } - else { - pushFile(file) - } - - } + const tree = this.$.$mol_tree2_from_string( source.text() , source.path() ) + tree.select( 'deploy' ).kids.forEach( deploy => { addFilesRecursive(root.resolve(deploy.text().replace( /^\// , '' ))) } ) - } ) + } return targets }