Skip to content

Commit 60649d9

Browse files
committed
Version 0.2.10: Solve several bugs
1 parent de6bbf6 commit 60649d9

File tree

10 files changed

+18
-26
lines changed

10 files changed

+18
-26
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
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": "azure-devops-bicep-task",
3-
"version": "0.2.7",
3+
"version": "0.2.10",
44
"description": "Tasks for installing Bicep CLI and running Bicep CLI build commands",
55
"main": "index.js",
66
"scripts": {

src/install/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"version": {
1717
"Major": 0,
1818
"Minor": 2,
19-
"Patch": 7
19+
"Patch": 10
2020
},
2121
"instanceNameFormat": "Install Bicep CLI",
2222
"inputs": [
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export function getFilesList(directory: string): string[] {
88
directoryToGetFiles = path.join(directoryToGetFiles, '**');
99
}
1010
directoryToGetFiles = directoryToGetFiles.replace(/\\/g, '/');
11-
return glob.sync(directoryToGetFiles);
11+
return glob.sync(directoryToGetFiles, { nodir: true });
1212
}
1313

14-
export function createDirectoryIfNotExists(directory: string): void {
15-
const dirnamePath = path.dirname(directory);
14+
export function createDirectoryIfNotExists(directory: string, checkDirname: boolean): void {
15+
const dirnamePath = checkDirname ? path.dirname(directory) : directory;
1616
if (!fs.existsSync(dirnamePath)) {
1717
fs.mkdirSync(dirnamePath, { recursive: true });
1818
}

src/run/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as path from 'path';
22
import { platform } from 'os';
33
import * as taskLib from 'azure-pipelines-task-lib/task';
44
import * as toolLib from 'azure-pipelines-tool-lib/tool';
5-
import { createDirectoryIfNotExists, getFilesList } from '../common/fileUtils';
6-
import { ProcessingType } from '../common/enums/processingType';
5+
import { createDirectoryIfNotExists, getFilesList } from './common/fileUtils';
6+
import { ProcessingType } from './common/enums/processingType';
77

88
let processType: string | undefined;
99
let sourceDirectory: string | undefined;
@@ -119,12 +119,12 @@ async function run() {
119119
} else if (outputFile && processingType === ProcessingType.Single) {
120120
additionalArgsByInputs.push('--outfile');
121121
additionalArgsByInputs.push(outputFile);
122-
createDirectoryIfNotExists(outputFile);
122+
createDirectoryIfNotExists(outputFile, true);
123123
} else if (outputDirectory) {
124124
taskLib.debug(`Output files will be stored in '${outputDirectory}'`);
125125
additionalArgsByInputs.push('--outdir');
126126
additionalArgsByInputs.push(outputDirectory);
127-
createDirectoryIfNotExists(outputDirectory);
127+
createDirectoryIfNotExists(outputDirectory, false);
128128
} else {
129129
taskLib.debug(
130130
`No output directory specified... Output files will be stored in source directory: '${sourceDirectory}'`,

src/run/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"version": {
1717
"Major": 0,
1818
"Minor": 2,
19-
"Patch": 7
19+
"Patch": 10
2020
},
2121
"instanceNameFormat": "Run Bicep CLI build command",
2222
"inputs": [
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from 'fs';
2-
import { createDirectoryIfNotExists, getFilesList } from '../../src/common/fileUtils';
2+
import { createDirectoryIfNotExists, getFilesList } from '../../../src/run/common/fileUtils';
33

44
jest.mock('fs');
55

@@ -35,7 +35,7 @@ describe('getFilesList perform valid actions', () => {
3535
getFilesList('./bicep_files');
3636
expect(globHasMagicMock).toHaveBeenCalled();
3737
expect(pathJoinMock).toHaveBeenCalled();
38-
expect(globSyncMock).toHaveBeenCalledWith('bicep_files/**');
38+
expect(globSyncMock).toHaveBeenCalledWith('bicep_files/**', { nodir: true });
3939
});
4040

4141
test('if path has wildcards', () => {
@@ -44,7 +44,7 @@ describe('getFilesList perform valid actions', () => {
4444
getFilesList('./bicep_files/*.bicep');
4545
expect(globHasMagicMock).toHaveBeenCalled();
4646
expect(pathJoinMock).not.toHaveBeenCalled();
47-
expect(globSyncMock).toHaveBeenCalledWith('./bicep_files/*.bicep');
47+
expect(globSyncMock).toHaveBeenCalledWith('./bicep_files/*.bicep', { nodir: true });
4848
});
4949
});
5050

@@ -54,15 +54,15 @@ describe('createDirectoryIfNotExists creates directory if not exists', () => {
5454
test('if path already exists', () => {
5555
prepareMocks(true);
5656

57-
createDirectoryIfNotExists('any_directory');
57+
createDirectoryIfNotExists('any_directory', false);
5858
expect(existsSyncMock).toHaveBeenCalled();
5959
expect(mkdirSyncMock).not.toHaveBeenCalled();
6060
});
6161

6262
test('if path not exists', () => {
6363
prepareMocks(false);
6464

65-
createDirectoryIfNotExists('any_directory');
65+
createDirectoryIfNotExists('any_directory', false);
6666
expect(existsSyncMock).toHaveBeenCalled();
6767
expect(mkdirSyncMock).toHaveBeenCalled();
6868
});

test/run/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ProcessingType } from '../../src/common/enums/processingType';
1+
import { ProcessingType } from '../../src/run/common/enums/processingType';
22
import { checkInputsAreValid, getProcessingTypeForFiles } from '../../src/run/index';
33

44
describe('checkInputsAreValid throws correct errors', () => {

vss-extension.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifestVersion": 1,
33
"id": "bicep-tasks",
4-
"version": "0.2.7",
4+
"version": "0.2.10",
55
"name": "Bicep Tasks",
66
"publisher": "piraces",
77
"description": "Provides Azure DevOps tasks to install and run Microsoft Bicep CLI commands (cross-platform)",
@@ -54,14 +54,6 @@
5454
{
5555
"path": "node_modules",
5656
"packagePath": "run/node_modules"
57-
},
58-
{
59-
"path": "src/common",
60-
"packagePath": "install/common"
61-
},
62-
{
63-
"path": "src/common",
64-
"packagePath": "run/common"
6557
}
6658
],
6759
"links": {

0 commit comments

Comments
 (0)