Skip to content

Commit

Permalink
fix: handle empty deps when cloud run target (#41)
Browse files Browse the repository at this point in the history
* fix: handle empty deps when cloud run target

* chore: cleanup comments
  • Loading branch information
jthegedus authored May 6, 2021
1 parent 6864b95 commit b7719bd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ async function adaptToCloudRun({utils, serviceId, region, cloudRunBuildDir}) {
utils.log.info(`Writing Cloud Run service to ./${serverOutputDir}`);

// Prepare Cloud Run package.json - read SvelteKit App 'package.json', modify the JSON, write to serverOutputDir
const pkgjson = JSON.parse(readFileSync('package.json', 'utf-8'));
const pkgjson = JSON.parse(readFileSync(fileURLToPath(new URL('package.json', import.meta.url)), 'utf-8'));
pkgjson.scripts.start = 'functions-framework --target=default';
pkgjson.dependencies['@google-cloud/functions-framework'] = '^1.7.1'; // Peer-dep of this adapter instead?
if (pkgjson.dependencies === undefined) {
pkgjson.dependencies = {};
}

pkgjson.dependencies['@google-cloud/functions-framework'] = '^1.7.1';
pkgjson.engines = {node: '14'};
delete pkgjson.type;
const data = JSON.stringify(pkgjson, null, 2);
Expand Down

0 comments on commit b7719bd

Please sign in to comment.