Skip to content

[suggestion] template string variables and/or project names #364

@Tythos

Description

@Tythos

Starting off a project from scratch, even using degit (which is one of my favorite tools--kudos!), the first think I typically have to do is a series of search-replace-all for the name of the project I am starting. It occurs to me that, aside from injecting a "project name" value into specific places, a basic template'd string variable might help automate the search-replace-all. Of course, there are plenty of other templating solutions for more sophisticated usages (no control flow or types/structuring needed here).

Maybe degit --name=my-new-project replaces {{name}} instances in files once written? Alternatively, I could see some sort of a global search-replace-all "action" supported. Wouldn't mind helping out in either case.

Hrm... you know what, that last option sounds like something I could probably whip into a PR. Keep it in degit.json to ensure it's a templating-specific pass and not project contents. Here's what it might look like:

// degit.json
[
	{
		"action": "search_replace",
		"files": [ "one.txt", "two.json", "three.mjs" ], // e.g., only replace from known/desired plaintext files, a property of the template
                "pattern": "\{\{project_name\}\}",
                "replacement": "project_name"
	}
]

...where "project_name" comes from a definition assigned at degit invocation:

$ degit [src] [dest] -Dproject_name=foobar

Hrm... Does this at least sound like something that wouldn't be rejected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions