custom-title icon indicating copy to clipboard operation
custom-title copied to clipboard

title from package.json?

Open zombieyang opened this issue 10 years ago • 1 comments

can we set the 'name' in package.json as the window title?

zombieyang avatar Jun 02 '15 12:06 zombieyang

This should work (put it as the "template" in the package settings):

<% var packageName; try { packageName = JSON.parse(require('fs').readFileSync(projectPath + '/package.json', {encoding: 'utf8'})).name; } catch (e) { packageName = ''; } if (packageName) { %><%= packageName %><% } else { %><%= projectName %><% } %>

It will attempt to read and parse the package.json at the root of the project (i.e. opened folder) and take the name from there, falling back to the regular projectName variable if a package.json name is not found.

Dragory avatar Jan 14 '16 12:01 Dragory