@@ -42,38 +42,37 @@ async function replaceCodePath(mdPath, samplesPath) {
42
42
await sh ( replaceCommand ) ;
43
43
}
44
44
45
- async function tryCopy ( pathElements , subFolderName , destinationPath ) {
46
- const sourcePath = path . join ( ...[ ... pathElements , subFolderName ] ) ;
45
+ async function tryCopy ( pathElements , destinationPath ) {
46
+ const sourcePath = path . join ( ...pathElements ) ;
47
47
48
48
if ( ! fs . existsSync ( sourcePath ) ) {
49
49
log . info ( `${ sourcePath } does not exist, skipping...` ) ;
50
50
return false ;
51
51
}
52
52
53
- log . info ( `${ subFolderName } exist, copying...` ) ;
53
+ log . info ( `${ sourcePath } exist, copying...` ) ;
54
54
55
55
await fsExtra . copy ( sourcePath , destinationPath ) ;
56
56
57
57
return true ;
58
58
}
59
59
60
- async function copyDocsAndSamples ( clientRepo , repoLocation , docsLocation , id , tag , relativePath ) {
60
+ async function copySamples ( clientRepo , repoLocation , destinationPath , id , tag , relativePath ) {
61
61
log . info ( `checking out ${ tag } ...` ) ;
62
62
await clientRepo . checkout ( tag ) ;
63
63
64
- const pathElements = [ repoLocation , ...( relativePath || [ 'docs' ] ) ] ;
64
+ const pathElements = [ repoLocation , ...relativePath ] ;
65
65
66
- const samplesDestinationPath = path . join ( docsLocation , id , 'samples' ) ;
67
- const docsDestinationPath = path . join ( docsLocation , id ) ;
66
+ const destinationPathWithId = path . join ( destinationPath , id ) ;
67
+ const samplesDestinationPath = path . join ( destinationPathWithId , 'samples' ) ;
68
68
69
- const wereDocsCopied = await tryCopy ( pathElements , 'docs' , docsDestinationPath ) ;
70
- const wereSamplesCopied = await tryCopy ( pathElements , 'samples' , samplesDestinationPath ) ;
69
+ const wereSamplesCopied = await tryCopy ( pathElements , samplesDestinationPath ) ;
71
70
72
- if ( ! wereDocsCopied && ! wereSamplesCopied ) {
71
+ if ( ! wereSamplesCopied ) {
73
72
return ;
74
73
}
75
74
76
- await replaceCodePath ( docsDestinationPath , samplesDestinationPath ) ;
75
+ await replaceCodePath ( destinationPathWithId , samplesDestinationPath ) ;
77
76
78
77
return { path : path . join ( 'generated' , id ) , version : id . substr ( 1 ) + ' gRPC' } ;
79
78
}
@@ -84,10 +83,10 @@ async function main() {
84
83
85
84
for ( const repo of repos ) {
86
85
const repoPath = path . join ( 'docs' , repo . basePath ) ;
87
- const docsLocation = path . join ( repoPath , 'generated' ) ;
86
+ const samplesLocation = path . join ( repoPath , 'generated' ) ;
88
87
const repoLocation = path . join ( 'temp' , repo . id ) ;
89
88
90
- await safeRmdir ( docsLocation ) ;
89
+ await safeRmdir ( samplesLocation ) ;
91
90
await git . clone ( repo . repo , repoLocation ) ;
92
91
93
92
const clientRepo = simpleGit ( repoLocation ) ;
@@ -108,11 +107,11 @@ async function main() {
108
107
. filter ( i => i )
109
108
110
109
if ( deployCurrent ) {
111
- definition [ 0 ] . versions . push ( await copyDocsAndSamples ( clientRepo , repoLocation , docsLocation , tags . slice ( - 1 ) [ 0 ] , repo . currentBranch , repo . relativePath ) ) ;
110
+ definition [ 0 ] . versions . push ( await copySamples ( clientRepo , repoLocation , samplesLocation , tags . slice ( - 1 ) [ 0 ] , repo . currentBranch , repo . relativePath ) ) ;
112
111
}
113
112
114
113
for ( let i = 0 ; i < tags . length - 1 ; i ++ ) {
115
- const version = await copyDocsAndSamples ( clientRepo , repoLocation , docsLocation , tags [ i ] , tags [ i + 1 ] ) ;
114
+ const version = await copySamples ( clientRepo , repoLocation , samplesLocation , tags [ i ] , tags [ i + 1 ] , repo . relativePath ) ;
116
115
117
116
if ( version !== undefined ) {
118
117
definition [ 0 ] . versions . push ( version ) ;
0 commit comments