Skip to content

Commit

Permalink
$mol_file copy api refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Oct 21, 2024
1 parent ffacb3c commit a27f8ab
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
5 changes: 2 additions & 3 deletions build/build.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ namespace $ {

return targets
}

@ $mol_mem_key
bundleFiles( [ path , exclude ] : [ path : string , exclude? : readonly string[] ] ) : $mol_file[] {
const root = this.root()
Expand All @@ -1423,8 +1423,7 @@ namespace $ {
}
const start = Date.now()

const target = file.clone(pack.resolve( `-/${ file.relate( root ) }` ).path())
target.stat()
const target = file.copy(pack.resolve( `-/${ file.relate( root ) }` ).path())

targets.push( target )
this.logBundle( target , Date.now() - start )
Expand Down
4 changes: 3 additions & 1 deletion file/file.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ namespace $ {

@ $mol_mem
override stat(next? : $mol_file_stat | null, virt?: 'virt') {
if (next === undefined) this.copy_sync()
let stat = next
const path = this.path()

Expand Down Expand Up @@ -114,8 +113,11 @@ namespace $ {

}

@ $mol_mem_key
override copy(to: string) {
this.stat()
$node.fs.copyFileSync(this.path(), to)
return this.$.$mol_file.absolute(to)
}

@ $mol_action
Expand Down
25 changes: 3 additions & 22 deletions file/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ namespace $ {
return this.resolve( '..' )
}

@ $mol_mem_key
clone(path: string) {
return ( this.constructor as typeof $mol_file ).make({
path: $mol_const(path),
copy_src: () => this.path()
})
}

stat(next? : $mol_file_stat | null, virt?: 'virt'): null | $mol_file_stat {
return null
}
Expand Down Expand Up @@ -125,20 +117,9 @@ namespace $ {
@ $mol_mem
buffer( next? : Uint8Array ) { return next ?? new Uint8Array }

@ $mol_mem
copy_src(path?: string) { return path ?? null }

copy(to: string) {}

@ $mol_mem
copy_sync() {
const src_path = this.copy_src()
if (! src_path) return false
const src = this.$.$mol_file.absolute(src_path)
src.stat()
src.copy(this.path())

return true
@ $mol_mem_key
copy(to: string): $mol_file {
throw new Error('not implemented')
}

@ $mol_mem
Expand Down
1 change: 0 additions & 1 deletion file/file.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace $ {

@ $mol_mem
override stat( next? : $mol_file_stat, virt?: 'virt' ) {
this.copy_sync()
let stat = next
if (next === undefined) {
const content = this.text()
Expand Down

0 comments on commit a27f8ab

Please sign in to comment.