Skip to content
Closed
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# Do not normalize line endings from CR LF to LF, regardless of core.autocrlf.
* -text

# Normalize C# source files to use CR LF line endings.
*.cs text eol=crlf
40 changes: 20 additions & 20 deletions Nodejs/Product/ProjectWizard/NodejsPackageParametersExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Text.RegularExpressions;
using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've tried but I can't undo this change. It's whitespace only but git refuses to see that anything has been changed even after checking out this file directly from this repo directly.

namespace Microsoft.NodejsTools.ProjectWizard {
class NodejsPackageParametersExtension : IWizard {
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) {
Expand All @@ -45,25 +45,25 @@ public void BeforeOpeningFile(ProjectItem projectItem) {

public void RunFinished() {
return;
}
private const int NpmPackageNameMaxLength = 214;
/// <summary>
/// Normalize a project name to be a valid Npm package name: https://docs.npmjs.com/files/package.json#name
/// </summary>
/// <param name="projectName">Name of a VS project.</param>
private static string NormalizeNpmPackageName(string projectName) {
// Remove all leading url-invalid, underscore, and period characters
var npmProjectNameTransform = Regex.Replace(projectName, "^[^a-zA-Z0-9-~]*", string.Empty);
// Replace all invalid characters with a dash
npmProjectNameTransform = Regex.Replace(npmProjectNameTransform, "[^a-zA-Z0-9-_~.]", "-");
// Insert hyphens between camelcased sections.
npmProjectNameTransform = Regex.Replace(npmProjectNameTransform, "([a-z0-9])([A-Z])", "$1-$2").ToLowerInvariant();
return npmProjectNameTransform.Substring(0, Math.Min(npmProjectNameTransform.Length, NpmPackageNameMaxLength));
}

private const int NpmPackageNameMaxLength = 214;

/// <summary>
/// Normalize a project name to be a valid Npm package name: https://docs.npmjs.com/files/package.json#name
/// </summary>
/// <param name="projectName">Name of a VS project.</param>
private static string NormalizeNpmPackageName(string projectName) {
// Remove all leading url-invalid, underscore, and period characters
var npmProjectNameTransform = Regex.Replace(projectName, "^[^a-zA-Z0-9-~]*", string.Empty);

// Replace all invalid characters with a dash
npmProjectNameTransform = Regex.Replace(npmProjectNameTransform, "[^a-zA-Z0-9-_~.]", "-");

// Insert hyphens between camelcased sections.
npmProjectNameTransform = Regex.Replace(npmProjectNameTransform, "([a-z0-9])([A-Z])", "$1-$2").ToLowerInvariant();

return npmProjectNameTransform.Substring(0, Math.Min(npmProjectNameTransform.Length, NpmPackageNameMaxLength));
}
}
}