Commit 41064ce 1 parent ae3b096 commit 41064ce Copy full SHA for 41064ce
File tree 6 files changed +17
-11
lines changed
6 files changed +17
-11
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @astrojs/vercel ' : patch
3
+ ' @astrojs/internal-helpers ' : patch
4
+ ---
5
+
6
+ Extracts fs helpers into shared internal-helpers module
Original file line number Diff line number Diff line change 1
1
import { relative as relativePath } from 'node:path' ;
2
2
import { fileURLToPath } from 'node:url' ;
3
3
import type { AstroIntegrationLogger } from 'astro' ;
4
- import { copyFilesToFunction } from './fs.js ' ;
4
+ import { copyFilesToFolder } from '@astrojs/internal-helpers/fs ' ;
5
5
6
6
export async function copyDependenciesToFunction (
7
7
{
@@ -72,7 +72,7 @@ export async function copyDependenciesToFunction(
72
72
}
73
73
}
74
74
75
- const commonAncestor = await copyFilesToFunction (
75
+ const commonAncestor = await copyFilesToFolder (
76
76
[ ...result . fileList ] . map ( ( file ) => new URL ( file , base ) ) . concat ( includeFiles ) ,
77
77
outDir ,
78
78
excludeFiles
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import {
16
16
getAstroImageConfig ,
17
17
getDefaultImageConfig ,
18
18
} from '../image/shared.js' ;
19
- import { removeDir , writeJson } from '../lib /fs.js ' ;
19
+ import { removeDir , writeJson } from '@astrojs/internal-helpers /fs' ;
20
20
import { copyDependenciesToFunction } from '../lib/nft.js' ;
21
21
import { escapeRegex , getRedirects } from '../lib/redirects.js' ;
22
22
import {
Original file line number Diff line number Diff line change 6
6
getAstroImageConfig ,
7
7
getDefaultImageConfig ,
8
8
} from '../image/shared.js' ;
9
- import { emptyDir , writeJson } from '../lib /fs.js ' ;
9
+ import { emptyDir , writeJson } from '@astrojs/internal-helpers /fs' ;
10
10
import { isServerLikeOutput } from '../lib/prerender.js' ;
11
11
import { getRedirects } from '../lib/redirects.js' ;
12
12
import {
Original file line number Diff line number Diff line change 12
12
},
13
13
"bugs" : " https://github.com/withastro/astro/issues" ,
14
14
"exports" : {
15
- "./path" : " ./dist/path.js"
15
+ "./path" : " ./dist/path.js" ,
16
+ "./fs" : " ./dist/fs.js"
16
17
},
17
18
"typesVersions" : {
18
19
"*" : {
19
20
"path" : [
20
21
" ./dist/path.d.ts"
22
+ ],
23
+ "fs" : [
24
+ " ./dist/fs.d.ts"
21
25
]
22
26
}
23
27
},
Original file line number Diff line number Diff line change @@ -40,15 +40,15 @@ export async function getFilesFromFolder(dir: URL) {
40
40
* @param {URL[] } [exclude] A list of files to exclude (absolute path).
41
41
* @returns {Promise<string> } The common ancestor of the copied files.
42
42
*/
43
- export async function copyFilesToFunction (
43
+ export async function copyFilesToFolder (
44
44
files : URL [ ] ,
45
45
outDir : URL ,
46
46
exclude : URL [ ] = [ ]
47
47
) : Promise < string > {
48
48
const excludeList = exclude . map ( fileURLToPath ) ;
49
49
const fileList = files . map ( fileURLToPath ) . filter ( ( f ) => ! excludeList . includes ( f ) ) ;
50
50
51
- if ( files . length === 0 ) throw new Error ( '[@astrojs/vercel] No files found to copy' ) ;
51
+ if ( files . length === 0 ) throw new Error ( 'No files found to copy' ) ;
52
52
53
53
let commonAncestor = nodePath . dirname ( fileList [ 0 ] ) ;
54
54
for ( const file of fileList . slice ( 1 ) ) {
@@ -87,7 +87,3 @@ export async function copyFilesToFunction(
87
87
88
88
return commonAncestor ;
89
89
}
90
-
91
- export async function writeFile ( path : PathLike , content : string ) {
92
- await fs . writeFile ( path , content , { encoding : 'utf-8' } ) ;
93
- }
You can’t perform that action at this time.
0 commit comments