Browse Source

Create .npmrc file when run abp switch-to-preview command

resolves https://github.com/abpframework/abp/issues/3258
pull/3480/head
Yunus Emre Kalkan 6 years ago
parent
commit
342db11296
  1. 23
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs

23
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
@ -51,9 +52,14 @@ namespace Volo.Abp.Cli.ProjectModification
{
var fileDirectory = Path.GetDirectoryName(file).EnsureEndsWith(Path.DirectorySeparatorChar);
if (IsAngularProject(fileDirectory))
{
CreateNpmrcFile(Path.GetDirectoryName(file));
}
RunYarn(fileDirectory);
if (IsAngularProject(fileDirectory) == false)
if (!IsAngularProject(fileDirectory))
{
Thread.Sleep(500);
RunGulp(fileDirectory);
@ -62,6 +68,21 @@ namespace Volo.Abp.Cli.ProjectModification
}
}
private void CreateNpmrcFile(string directoryName)
{
var fileName = Path.Combine(directoryName, ".npmrc");
if (File.Exists(fileName))
{
return;
}
using var fs = File.Create(fileName);
var content = new UTF8Encoding(true).GetBytes("@abp:registry:https://www.myget.org/F/abp-nightly/npm");
fs.Write(content, 0, content.Length);
}
private bool IsAngularProject(string fileDirectory)
{
return File.Exists(Path.Combine(fileDirectory, "angular.json"));

Loading…
Cancel
Save