diff --git a/package.json b/package.json index b14fe634..4384b3d5 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "dev": "node server/node/server.js & npm run webhook", "setup-products": "node server/node/setup.js", "webhook": "stripe listen --project-name=stripe-payments-demo --forward-to http://localhost:8000/webhook", - "postinstall": "brew install stripe/stripe-cli/stripe && npm run setup-products" + "postinstall": "npm run setup-products && brew install stripe/stripe-cli/stripe" }, "dependencies": { "body-parser": "^1.17.1", diff --git a/server/node/setup.js b/server/node/setup.js index dc8a3bc9..fd3f6808 100644 --- a/server/node/setup.js +++ b/server/node/setup.js @@ -75,16 +75,20 @@ const createStoreProducts = async () => { // Set up the Stripe CLI. // https://github.com/stripe/stripe-cli const writeCLIConfig = async () => { - const configFilePath = `${process.env.HOME}/.config/stripe/config.toml`; + const configFilePath = `${process.env.HOME}/.config/stripe`; const stripeCLIConfig = ` [stripe-payments-demo] device_name = "stripe-payments-demo" secret_key = "${config.stripe.secretKey}" `; - fs.readFile(configFilePath, function(err, data) { + if (!fs.existsSync(configFilePath)) { + fs.mkdirSync(configFilePath); + } + + fs.readFile(`${configFilePath}/config.toml`, function(err, data) { if (err || !data.includes('stripe-payments-demo')) { - fs.appendFileSync(configFilePath, stripeCLIConfig); + fs.appendFileSync(`${configFilePath}/config.toml`, stripeCLIConfig); console.log(`Stripe CLI configuration set up.`); } });