@autorest/powershell
Version:
AutoRest PowerShell Cmdlet Generator
34 lines (31 loc) • 1.76 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.generatePsm1Custom = void 0;
const psscript_file_1 = require("../file-formats/psscript-file");
const path_1 = require("path");
async function generatePsm1Custom(project) {
const psm1 = new psscript_file_1.PSScriptFile(await project.state.readFile(project.psm1Custom) || '');
const dllPath = (0, path_1.relative)(project.customFolder, project.dll);
const internalPath = (0, path_1.relative)(project.customFolder, project.psm1Internal);
psm1.prepend('Generated', `
# Load the private module dll
$null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '${dllPath}')
# Load the internal module
$internalModulePath = Join-Path $PSScriptRoot '${internalPath}'
if(Test-Path $internalModulePath) {
$null = Import-Module -Name $internalModulePath
}
# Export nothing to clear implicit exports
Export-ModuleMember
# Export script cmdlets
Get-ChildItem -Path $PSScriptRoot -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot) -Alias (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot -AsAlias)`);
psm1.trim();
project.state.writeFile(project.psm1Custom, `${psm1}`, undefined, 'source-file-powershell');
}
exports.generatePsm1Custom = generatePsm1Custom;
//# sourceMappingURL=psm1.custom.js.map
;