Skip to content

Commit 3671cc9

Browse files
authored
[Dev tool] Clean doc for artifact-path (Azure#15336)
1 parent 4e7d629 commit 3671cc9

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

common/tools/dev-tool/src/commands/samples/checkNodeVersions.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { createPrinter } from "../../util/printer";
1111
import { leafCommand, makeCommandInfo } from "../../framework/command";
1212
import { S_IRWXO } from "constants";
1313
import { resolveProject } from "../../util/resolveProject";
14+
import { findSamplesRelativeDir } from "../../util/findSamplesDir";
1415

1516
const log = createPrinter("check-node-versions-samples");
1617

@@ -68,25 +69,6 @@ async function cleanup(
6869
await deleteDockerImages(dockerImageNames);
6970
}
7071

71-
function findSamplesDir(samplesDir: string, rootDir: string): string {
72-
const dirs = [];
73-
for (const file of fs.readdirSync(samplesDir)) {
74-
const stats = fs.statSync(path.join(samplesDir, file));
75-
if (stats.isDirectory()) {
76-
if (file.match(/^v[0-9]*.*$/)) {
77-
dirs.push(file);
78-
}
79-
}
80-
}
81-
if (dirs.length === 0) {
82-
return `${rootDir}/samples`;
83-
} else {
84-
return `${rootDir}/samples/${dirs
85-
.sort()
86-
.slice(-1)
87-
.pop()}`;
88-
}
89-
}
9072
function buildRunSamplesScript(
9173
containerWorkspacePath: string,
9274
samplesPath: string,
@@ -97,7 +79,7 @@ function buildRunSamplesScript(
9779
function compileCMD(cmd: string, printToScreen?: boolean) {
9880
return printToScreen ? cmd : `${cmd} >> ${logFilePath} 2>&1`;
9981
}
100-
const samplesDir = findSamplesDir(samplesPath, containerWorkspacePath);
82+
const samplesDir = `${containerWorkspacePath}/${findSamplesRelativeDir(samplesPath)}`;
10183
const printToScreen = logFilePath === undefined;
10284
const envFilePath = `${containerWorkspacePath}/${envFileName}`;
10385
const javascriptSamplesPath = `${samplesDir}/javascript`;
@@ -232,7 +214,7 @@ export const commandInfo = makeCommandInfo(
232214
{
233215
"artifact-path": {
234216
kind: "string",
235-
description: "Path to the downloaded artifact built by the release pipeline"
217+
description: "The URL/path to the artifact built by the release pipeline"
236218
},
237219
directory: {
238220
kind: "string",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license
3+
4+
import fs from "fs-extra";
5+
import path from "path";
6+
7+
export function findSamplesRelativeDir(samplesDir: string): string {
8+
const dirs = [];
9+
for (const file of fs.readdirSync(samplesDir)) {
10+
const stats = fs.statSync(path.join(samplesDir, file));
11+
if (stats.isDirectory()) {
12+
if (file.match(/^v[0-9]*.*$/)) {
13+
dirs.push(file);
14+
}
15+
}
16+
}
17+
if (dirs.length === 0) {
18+
return `samples`;
19+
} else {
20+
return `samples/${dirs
21+
.sort()
22+
.slice(-1)
23+
.pop()}`;
24+
}
25+
}

0 commit comments

Comments
 (0)