Skip to content

Commit

Permalink
who creates package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
claasahl committed Jan 3, 2019
1 parent 7fe7fff commit d5f94b6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 204 deletions.
180 changes: 6 additions & 174 deletions build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 6 additions & 29 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
#!/usr/bin/env node
import execa from "execa";
import init from "init-package-json";
import path from "path";

const HOME = process.env.HOME || ".";
// a path to a promzard module. In the event that this file is
// not found, one will be provided for you.
const initFile = path.resolve(HOME, ".npm-init");

// the dir where we're doin stuff.
const dir = process.cwd();

// extra stuff that gets put into the PromZard module's context.
// In npm, this is the resolved config object. Exposed as 'config'
// Optional.
const configData = { some: "extra stuff" };

// Any existing stuff from the package.json file is also exposed in the
// PromZard module as the `package` object. There will also be free
// vars for:
// * `filename` path to the package.json file
// * `basename` the tip of the package dir
// * `dirname` the parent of the package dir

init(dir, initFile, configData, function(_er, _data) {
// the data's already been written to {dir}/package.json
// now you can do stuff with it
(async () => {
await execa("npm", ["install", "typescript", "@types/node", "--save-dev"]);
await execa("tsc", ["--init"]);
})();
});
const packageFile = path.resolve(dir, "package.json");
if (packageFile) {
console.log("Found package.json:", packageFile);
} else {
console.log("Did not find package.json");
}

0 comments on commit d5f94b6

Please sign in to comment.