Skip to content

Commit 42de560

Browse files
Fix lint
1 parent 5381f68 commit 42de560

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

packages/blocks/terraform/src/lib/hcledit-cli.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function validateIdentifier(value: string, fieldName: string): void {
1919

2020
/**
2121
* Escapes a string for safe use as a shell argument.
22-
*
22+
*
2323
* This function wraps the input value in single quotes and escapes any embedded single quotes
2424
* using the POSIX shell pattern: '\''. This is the standard technique for safely passing
2525
* arbitrary strings as arguments to POSIX-compliant shells.
@@ -36,7 +36,9 @@ export async function getResources(
3636
): Promise<TerraformResource[]> {
3737
const commandResult = await useTempFile(template, async (filePath) => {
3838
return await executeHclEditCommand(
39-
`-f ${escapeShellArgument(filePath)} block get resource | hcledit block list`,
39+
`-f ${escapeShellArgument(
40+
filePath,
41+
)} block get resource | hcledit block list`,
4042
);
4143
});
4244

@@ -96,7 +98,10 @@ export async function updateResourceProperties(
9698
validateIdentifier(resourceName, 'Resource name');
9799

98100
modifications.forEach((modification, index) => {
99-
validateIdentifier(modification.propertyName, `Property name at index ${index}`);
101+
validateIdentifier(
102+
modification.propertyName,
103+
`Property name at index ${index}`,
104+
);
100105
});
101106

102107
const providedTemplate = template.trim() as string;
@@ -165,7 +170,9 @@ export async function deleteResource(
165170

166171
const commandResult = await useTempFile(template, async (filePath) => {
167172
return await executeHclEditCommand(
168-
`-f ${escapeShellArgument(filePath)} block rm resource.${resourceType}.${resourceName}`,
173+
`-f ${escapeShellArgument(
174+
filePath,
175+
)} block rm resource.${resourceType}.${resourceName}`,
169176
);
170177
});
171178

@@ -199,7 +206,9 @@ async function getAttributeCommand(
199206
resourceName: string,
200207
propertyName: string,
201208
): Promise<string> {
202-
const command = `-f ${escapeShellArgument(filePath)} attribute get resource.${resourceType}.${resourceName}.${propertyName}`;
209+
const command = `-f ${escapeShellArgument(
210+
filePath,
211+
)} attribute get resource.${resourceType}.${resourceName}.${propertyName}`;
203212

204213
const commandResult = await executeHclEditCommand(command);
205214

@@ -218,7 +227,9 @@ async function updateTemplateCommand(
218227
filePath: string,
219228
modifications: string[],
220229
): Promise<string> {
221-
const command = `-f ${escapeShellArgument(filePath)} ${modifications.join(' | hcledit ')}`;
230+
const command = `-f ${escapeShellArgument(filePath)} ${modifications.join(
231+
' | hcledit ',
232+
)}`;
222233

223234
const commandResult = await executeHclEditCommand(command);
224235

packages/blocks/terraform/test/hcledit-cli.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,9 @@ describe('Update Resource Properties', () => {
246246
expectedMessage,
247247
}) => {
248248
await expect(
249-
updateResourceProperties(
250-
testTemplate,
251-
resourceType,
252-
resourceName,
253-
[{ propertyName, propertyValue: 'value' }],
254-
),
249+
updateResourceProperties(testTemplate, resourceType, resourceName, [
250+
{ propertyName, propertyValue: 'value' },
251+
]),
255252
).rejects.toThrow(expectedMessage);
256253
expect(mockExecuteCommand).not.toHaveBeenCalled();
257254
expect(mockWriteFile).not.toHaveBeenCalled();
@@ -359,7 +356,9 @@ describe('Update Variables File', () => {
359356

360357
test('should reject invalid variable names', async () => {
361358
await expect(
362-
updateVariablesFile('a=1', [{ variableName: 'name; rm -rf /', variableValue: 3 }]),
359+
updateVariablesFile('a=1', [
360+
{ variableName: 'name; rm -rf /', variableValue: 3 },
361+
]),
363362
).rejects.toThrow('Variable name at index 0 contains invalid characters');
364363
expect(mockExecuteCommand).not.toHaveBeenCalled();
365364
expect(mockWriteFile).not.toHaveBeenCalled();

0 commit comments

Comments
 (0)