Skip to content

Commit d4553ec

Browse files
committed
fix(api): add filePath for compat with twilio-run
re #8
1 parent b2588da commit d4553ec

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/types/generic.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ export type ServerlessResourceConfig = {
3535
path?: string;
3636
};
3737

38+
export type ServerlessResourceConfigWithFilePath = ServerlessResourceConfig & {
39+
/**
40+
* Path to the actual file on the file system.
41+
*/
42+
filePath: string;
43+
};
44+
3845
export type FunctionResource = ServerlessResourceConfig & {
3946
sid: string;
4047
};
@@ -61,6 +68,6 @@ export type ResourcePathAndAccess = {
6168
};
6269

6370
export type DirectoryContent = {
64-
assets: ServerlessResourceConfig[];
65-
functions: ServerlessResourceConfig[];
71+
assets: ServerlessResourceConfigWithFilePath[];
72+
functions: ServerlessResourceConfigWithFilePath[];
6673
};

src/utils/fs.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import {
99
AccessOptions,
1010
DirectoryContent,
1111
FileInfo,
12-
ServerlessResourceConfig,
1312
ResourcePathAndAccess,
13+
ServerlessResourceConfig,
14+
ServerlessResourceConfigWithFilePath,
1415
} from '../types';
1516

1617
const log = debug('twilio-serverless-api:fs');
@@ -226,7 +227,7 @@ export async function getListOfFunctionsAndAssets(
226227
async function getServerlessConfigs(
227228
dirContent: FileInfo[],
228229
ignoreExtension?: string
229-
): Promise<ServerlessResourceConfig[]> {
230+
): Promise<ServerlessResourceConfigWithFilePath[]> {
230231
return Promise.all(
231232
dirContent.map(async file => {
232233
const { path, access } = getPathAndAccessFromFileInfo(
@@ -241,6 +242,7 @@ async function getServerlessConfigs(
241242
path,
242243
access,
243244
content,
245+
filePath: file.path,
244246
};
245247
})
246248
);

0 commit comments

Comments
 (0)