Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/pkg/override/cdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (cdk *CDK) transform(body []byte) ([]byte, error) {

// We assume that a node_modules/ dir is present with the CDK downloaded after running "npm install".
// This way clients don't need to install the CDK toolkit separately.
cmd := cdk.exec.Command(filepath.Join("node_modules", "aws-cdk", "bin", "cdk"), "synth", "--no-version-reporting")
cmd := cdk.exec.Command(filepath.Join("node_modules", ".bin", "cdk"), "synth", "--no-version-reporting")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the .bin/cdk file's content look like out of curiosity?

Copy link
Copy Markdown
Contributor Author

@Lou1415926 Lou1415926 Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks the same as aws-cdk/bin/cdk on Unix systems, but on Windows it looked different! After I got home I can check on my little Windows machine.

Putting the DNM label on so that i can post the snippet before it's merged!

Copy link
Copy Markdown
Contributor

@dannyrandall dannyrandall Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(on windows) node_modules/.bin/cdk:

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  exec "$basedir/node"  "$basedir/../aws-cdk/bin/cdk" "$@"
else 
  exec node  "$basedir/../aws-cdk/bin/cdk" "$@"
fi

(on mac) node_modules/.bin/cdk

#!/usr/bin/env node
require('./cdk.js');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty!

buf := new(bytes.Buffer)
cmd.Stdout = buf
cmd.Stderr = cdk.execWriter
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/override/cdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestCDK_Override(t *testing.T) {
return "/bin/npm", nil
},
CommandFn: func(name string, args ...string) *exec.Cmd {
if name == filepath.Join("node_modules", "aws-cdk", "bin", "cdk") {
if name == filepath.Join("node_modules", ".bin", "cdk") {
return exec.Command("exit", "42")
}
return exec.Command("echo", "success")
Expand All @@ -108,7 +108,7 @@ func TestCDK_Override(t *testing.T) {
require.ErrorContains(t, err, `run "exit 42"`)
})
t.Run("should invoke npm install and cdk synth", func(t *testing.T) {
binPath := filepath.Join("node_modules", "aws-cdk", "bin", "cdk")
binPath := filepath.Join("node_modules", ".bin", "cdk")
buf := new(strings.Builder)
cdk := WithCDK("", CDKOpts{
ExecWriter: buf,
Expand Down