Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
Fix CLI setup script.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten-stripe committed Aug 15, 2019
1 parent b310ffe commit 540a33e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 7 additions & 3 deletions server/node/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
}
});
Expand Down

0 comments on commit 540a33e

Please sign in to comment.