Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Run 'npm install' after generating and before publishing #2680

Merged
2 commits merged into from
Apr 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ function getServiceNameFromOutputFolderValue(outputFolderValue) {
return outputFolderSegments[outputFolderSegments.length - 1];
}

function npmInstall(packageFolderPath) {
execSync(`npm install`, { cwd: packageFolderPath, stdio: ['ignore', 'ignore', 'pipe'] });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this make it so we only see errors from the child process?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

}

gulp.task('default', function () {
console.log('Usage: gulp codegen [--azure-rest-api-specs-root <azure-rest-api-specs root>] [--use <autorest.nodejs root>] [--package <package name>]\n');
console.log('--azure-rest-api-specs-root');
Expand Down Expand Up @@ -81,7 +85,7 @@ gulp.task('codegen', function (cb) {

const nodejsReadmeFileContents = fs.readFileSync(nodejsReadmeFilePath, 'utf8');
const packageName = getPackageNameFromReadmeNodejsMdFileContents(nodejsReadmeFileContents);

if (!package || package === packageName || packageName.endsWith(`-${package}`)) {
console.log(`>>>>>>>>>>>>>>>>>>> Start: "${packageName}" >>>>>>>>>>>>>>>>>>>>>>>>>`);

Expand All @@ -100,6 +104,12 @@ gulp.task('codegen', function (cb) {
const result = execSync(cmd, { encoding: 'utf8' });
console.log('Output:');
console.log(result);

console.log('Installing dependencies...');
const outputFolderPath = getOutputFolderFromReadmeNodeJsMdFileContents(nodejsReadmeFileContents);
const outputFolderPathRelativeToAzureSDKForNodeRepoRoot = outputFolderPath.substring('$(node-sdks-folder)/'.length);
const packageFolderPath = path.resolve(azureSDKForNodeRepoRoot, outputFolderPathRelativeToAzureSDKForNodeRepoRoot);
npmInstall(packageFolderPath);
} catch (err) {
console.log('Error:');
console.log(`An error occurred while generating client for package: "${packageName}":\n ${err.stderr}`);
Expand Down Expand Up @@ -285,6 +295,7 @@ gulp.task('publish-packages', (cb) => {
else {
console.log(`Publishing package "${packageName}" with version "${localPackageVersion}"...`);
try {
npmInstall(packageFolderPath);
execSync(`npm publish`, { cwd: packageFolderPath });
publishedPackages++;
}
Expand Down