ci: fix gulp move for multi-application samples

This commit is contained in:
Jan Krueger
2021-07-09 18:59:03 +02:00
parent a0557c752b
commit d4739e817a

View File

@@ -1,7 +1,7 @@
import { dest, src, task } from 'gulp';
import { join } from 'path';
import { samplePath } from '../config';
import { getDirs } from '../util/task-helpers';
import { containsPackageJson, getDirs } from '../util/task-helpers';
/**
* Moves the compiled nest files into the `samples/*` dirs.
@@ -10,7 +10,22 @@ function move() {
const samplesDirs = getDirs(samplePath);
const distFiles = src(['node_modules/@nestjs/**/*']);
return samplesDirs.reduce(
/**
* Flatten the sampleDirs
* If a sample dir contains does not contain a package.json
* Push the subDirs into the destinations instead
*/
const flattenedSampleDirs: string[] = [];
for (const sampleDir of samplesDirs) {
if (containsPackageJson(sampleDir)) {
flattenedSampleDirs.push(sampleDir);
} else {
flattenedSampleDirs.push(...getDirs(sampleDir));
}
}
return flattenedSampleDirs.reduce(
(distFile, dir) => distFile.pipe(dest(join(dir, '/node_modules/@nestjs'))),
distFiles,
);