@nx-dotnet/core
Version:
- Have an existing nx workspace. For creating this, see [nrwl's documentation](https://nx.dev/latest/angular/getting-started/nx-setup). - .NET SDK is installed, and `dotnet` is available on the path. For help on this, see [Microsoft's documentation](https
30 lines • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.runDotnetNew = runDotnetNew;
exports.copyFilesToTree = copyFilesToTree;
const devkit_1 = require("@nx/devkit");
const fs_1 = require("fs");
const path_1 = require("path");
const tmp_1 = require("tmp");
function runDotnetNew(tree, dotnetClient, template, dotnetNewOptions, additionalArguments) {
const { name: tmpDir } = (0, tmp_1.dirSync)();
const { output, ...otherOptions } = dotnetNewOptions;
dotnetClient.new(template, {
...otherOptions,
output: tmpDir,
}, additionalArguments);
copyFilesToTree(tree, tmpDir, typeof output === 'string' ? output : '.');
(0, fs_1.rmSync)(tmpDir, { recursive: true });
}
function copyFilesToTree(tree, dir, dest) {
const children = (0, fs_1.readdirSync)(dir, { withFileTypes: true });
for (const child of children) {
if (child.isDirectory()) {
copyFilesToTree(tree, (0, path_1.join)(dir, child.name), (0, devkit_1.joinPathFragments)(dest, child.name));
}
else {
tree.write((0, devkit_1.joinPathFragments)(dest, child.name), (0, fs_1.readFileSync)((0, path_1.join)(dir, child.name)));
}
}
}
//# sourceMappingURL=dotnet-new.js.map