Skip to content

Commit 8377577

Browse files
committed
update example
1 parent 4415733 commit 8377577

File tree

4 files changed

+138
-4
lines changed

4 files changed

+138
-4
lines changed

examples/build-package/main.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,21 @@ module "package_with_commands_and_patterns" {
247247
# Some use cases might require the production packages are deployed while maintaining local node_modules folder
248248
# This example saves the node_modules folder by moving it to an ignored directory
249249
# After the zip file is created with production node_modules, the dev node_modules folder is restored
250-
module "package_with_commands_and_patterns" {
250+
module "npm_package_with_commands_and_patterns" {
251251
source = "../../"
252252

253+
create_function = false
254+
253255
runtime = "nodejs18.x"
254256
source_path = [
255257
{
256-
path = "./app"
258+
path = "${path.module}/../fixtures/node-app"
257259
commands = [
258-
"mv ./node_modules ./node_modules_temp",
260+
"[ ! -d node_modules ] || mv node_modules node_modules_temp",
259261
"npm ci --production",
260262
":zip",
261263
"rm -rf node_modules",
262-
"mv ./node_modules_temp ./node_modules",
264+
"[ ! -d node_modules_temp ] || mv node_modules_temp node_modules",
263265
]
264266
patterns = [
265267
"!node_modules_temp/.*"

tests/fixtures/node-app/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// test

tests/fixtures/node-app/package-lock.json

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/fixtures/node-app/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "app",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"dependencies": {
12+
},
13+
"devDependencies": {
14+
"axios": "^1.7.3"
15+
}
16+
}

0 commit comments

Comments
 (0)