Skip to content

Commit 51fb82c

Browse files
committed
release: v0.3.3
1 parent d1bb2ad commit 51fb82c

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@geek-fun/serverlessinsight",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "Full life cycle cross providers serverless application management for your fast-growing business.",
55
"homepage": "https://serverlessinsight.geekfun.club",
66
"main": "dist/src/index.js",

src/common/context.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Context, ServerlessIac } from '../types';
22
import path from 'node:path';
3+
import fs from 'node:fs';
34
import { ProviderEnum } from './providerEnum';
45
import { AsyncLocalStorage } from 'node:async_hooks';
56
import { getIamInfo } from './imsClient';
@@ -8,12 +9,31 @@ const asyncLocalStorage = new AsyncLocalStorage<Context>();
89

910
export const getIacLocation = (location?: string): string => {
1011
const projectRoot = path.resolve(process.cwd());
11-
return location
12-
? path.resolve(projectRoot, location)
13-
: path.resolve(projectRoot, 'serverlessinsight.yml') ||
14-
path.resolve(projectRoot, 'serverlessInsight.yml') ||
15-
path.resolve(projectRoot, 'ServerlessInsight.yml') ||
16-
path.resolve(projectRoot, 'serverless-insight.yml');
12+
if (location) {
13+
const candidate = path.isAbsolute(location) ? location : path.resolve(projectRoot, location);
14+
if (fs.existsSync(candidate)) {
15+
return candidate;
16+
}
17+
throw new Error(`IaC file not found at '${candidate}'`);
18+
}
19+
20+
const candidates = [
21+
'serverlessinsight.yml',
22+
'serverlessInsight.yml',
23+
'ServerlessInsight.yml',
24+
'serverless-insight.yml',
25+
];
26+
27+
for (const name of candidates) {
28+
const candidate = path.resolve(projectRoot, name);
29+
if (fs.existsSync(candidate)) {
30+
return candidate;
31+
}
32+
}
33+
34+
throw new Error(
35+
`No IaC file found. Tried: ${candidates.map((n) => `'${path.resolve(projectRoot, n)}'`).join(', ')}`,
36+
);
1737
};
1838

1939
export const setContext = async (

0 commit comments

Comments
 (0)