1
1
( window as any ) . process = require ( 'process/browser' ) ;
2
2
( window as any ) . Buffer = require ( 'buffer' ) . Buffer ;
3
3
4
- import { strictEqual , deepEqual } from 'assert' ;
4
+ import { strictEqual , deepEqual } from 'assert' ;
5
5
6
6
import type * as fsa from '../../src/fsa/types' ;
7
- import { FsaNodeFs , FsaNodeSyncAdapterWorker } from '../../src/fsa-to-node' ;
7
+ import { FsaNodeFs , FsaNodeSyncAdapterWorker } from '../../src/fsa-to-node' ;
8
8
9
9
const demo = async ( dir : fsa . IFileSystemDirectoryHandle ) => {
10
10
const adapter = await FsaNodeSyncAdapterWorker . start ( 'https://localhost:9876/worker.js' , dir ) ;
@@ -17,22 +17,22 @@ const demo = async (dir: fsa.IFileSystemDirectoryHandle) => {
17
17
18
18
console . log ( 'existsSync()' ) ;
19
19
strictEqual ( fs . existsSync ( '/test.txt' ) , true ) ;
20
-
20
+
21
21
console . log ( 'statSync() - returns correct type for file' ) ;
22
22
strictEqual ( fs . statSync ( '/test.txt' ) . isFile ( ) , true ) ;
23
23
strictEqual ( fs . statSync ( '/test.txt' ) . isDirectory ( ) , false ) ;
24
-
24
+
25
25
console . log ( 'statSync() - returns correct type for directory' ) ;
26
26
strictEqual ( fs . statSync ( '/dir' ) . isFile ( ) , false ) ;
27
27
strictEqual ( fs . statSync ( '/dir' ) . isDirectory ( ) , true ) ;
28
-
28
+
29
29
console . log ( 'readFileSync() - can read file as text' ) ;
30
30
strictEqual ( fs . readFileSync ( '/test.txt' , 'utf8' ) , 'Hello world!' ) ;
31
-
31
+
32
32
console . log ( 'writeFileSync() - can write text to a new file' ) ;
33
33
fs . writeFileSync ( '/cool.txt' , 'worlds' ) ;
34
34
strictEqual ( fs . readFileSync ( '/cool.txt' , 'utf8' ) , 'worlds' ) ;
35
-
35
+
36
36
console . log ( 'appendFileSync() - can append to an existing file' ) ;
37
37
fs . appendFileSync ( '/cool.txt' , '!' ) ;
38
38
strictEqual ( fs . readFileSync ( '/cool.txt' , 'utf8' ) , 'worlds!' ) ;
@@ -58,7 +58,7 @@ const demo = async (dir: fsa.IFileSystemDirectoryHandle) => {
58
58
strictEqual ( fs . existsSync ( '/dir/tmp' ) , false ) ;
59
59
60
60
console . log ( 'mkdirSync() - can create a nested directory' ) ;
61
- fs . mkdirSync ( '/public/site/assets/img' , { recursive : true } ) ;
61
+ fs . mkdirSync ( '/public/site/assets/img' , { recursive : true } ) ;
62
62
strictEqual ( fs . statSync ( '/public/site/assets/img' ) . isDirectory ( ) , true ) ;
63
63
64
64
console . log ( 'mkdtempSync() - can create a temporary directory' ) ;
@@ -81,7 +81,7 @@ const demo = async (dir: fsa.IFileSystemDirectoryHandle) => {
81
81
deepEqual ( listInDir , [ 'very-cool.txt' ] ) ;
82
82
83
83
console . log ( 'readdirSync() - can list files in a directory as Dirent[]' ) ;
84
- const listInDir2 = fs . readdirSync ( '/dir' , { withFileTypes : true } ) as any ;
84
+ const listInDir2 = fs . readdirSync ( '/dir' , { withFileTypes : true } ) as any ;
85
85
deepEqual ( listInDir2 [ 0 ] . name , 'very-cool.txt' ) ;
86
86
deepEqual ( listInDir2 [ 0 ] . isFile ( ) , true ) ;
87
87
@@ -108,16 +108,16 @@ const demo = async (dir: fsa.IFileSystemDirectoryHandle) => {
108
108
} ;
109
109
110
110
const main = async ( ) => {
111
- const button = document . createElement ( " button" ) ;
112
- button . textContent = " Select an empty folder" ;
111
+ const button = document . createElement ( ' button' ) ;
112
+ button . textContent = ' Select an empty folder' ;
113
113
document . body . appendChild ( button ) ;
114
114
button . onclick = async ( ) => {
115
- const dir = await ( window as any ) . showDirectoryPicker ( { id : 'demo' , mode : 'readwrite' } ) ;
115
+ const dir = await ( window as any ) . showDirectoryPicker ( { id : 'demo' , mode : 'readwrite' } ) ;
116
116
await demo ( dir ) ;
117
117
} ;
118
118
119
- const button2 = document . createElement ( " button" ) ;
120
- button2 . textContent = " Run tests in OPFS" ;
119
+ const button2 = document . createElement ( ' button' ) ;
120
+ button2 . textContent = ' Run tests in OPFS' ;
121
121
button2 . style . marginLeft = '1em' ;
122
122
document . body . appendChild ( button2 ) ;
123
123
button2 . onclick = async ( ) => {
@@ -126,4 +126,4 @@ const main = async () => {
126
126
} ;
127
127
} ;
128
128
129
- main ( ) ;
129
+ main ( ) ;
0 commit comments