Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix setup on Windows and update README for Windows.
Browse files Browse the repository at this point in the history
mpiroc committed Jul 11, 2018
1 parent 28f7905 commit c269d8a
Showing 7 changed files with 43 additions and 4 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -39,19 +39,37 @@ aws s3 cp <s3-url> ~/aws-cdk.zip

Once you've downloaded the bits, install them into `~/.cdk`:

#### Linux/MacOS (Shell)

```shell
rm -fr ~/.cdk
mkdir ~/.cdk
unzip <path-to-zip-file> -d ~/.cdk
```

#### Windows (PowerShell)
```powershell
Remove-Item -Force -Recurse ~/.cdk
New-Item -Type Directory ~/.cdk
Expand-Archive -Path <path-to-zip-file> -DestinationPath ~/.cdk
```

Make sure the `~/.cdk/bin` is in your `PATH`

#### Linux/MacOS (Shell)

```shell
# at the end of your ~/.bashrc or ~/.zshrc file
export PATH=$PATH:$HOME/.cdk/bin
```

#### Windows (PowerShell)

```powershell
$profilePath = Join-Path ([Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments)) "Profile.ps1"
Add-Content -Path $profilePath -Value '$env:Path = "$env:Path;$env:UserProfile\.cdk\bin"'
```

Install (or update) `aws-cdk` and `aws-cdk-docs` globally

```shell
3 changes: 3 additions & 0 deletions bundle-beta.sh
Original file line number Diff line number Diff line change
@@ -39,6 +39,9 @@ done

echo "Installing y-npm" # using y-npm, we're so META!
${Y_NPM} install --global-style --no-save y-npm
# Because y-npm is installed on the build server, we need to bootstrap
# it on windows by manually creating the shim batch file.
cp ${root}/tools/y-npm/bin/.y-npm.cmd node_modules/.bin/y-npm.cmd
ln -s node_modules/.bin bin

# Create a local maven repository
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
"%name%": "bin/%name%.js"
},
"scripts": {
"prepare": "tsc && chmod a+x bin/%name%.js",
"prepare": "node scripts/prepare.js",
"watch": "tsc -w",
"cdk": "cdk"
},
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const child_process = require('child_process')
const os = require('os')

child_process.spawn('tsc')

if (os.platform() !== 'win32') {
child_process.spawn('chmod', [ 'a+x', 'bin/%name%.js' ])
}
7 changes: 5 additions & 2 deletions packages/aws-cdk/lib/init.ts
Original file line number Diff line number Diff line change
@@ -201,7 +201,10 @@ async function postInstall(language: string) {
}

async function postInstallTypescript() {
const yNpm = path.join(CDK_HOME, 'bin', 'y-npm');

const yNpm = os.platform() === 'win32' ?
path.join(CDK_HOME, 'node_modules', '.bin', 'y-npm.cmd') :
path.join(CDK_HOME, 'bin', 'y-npm');
const command = await fs.pathExists(yNpm) ? yNpm : 'npm';
print(`Executing ${colors.green(`${command} install`)}...`);
try {
@@ -245,7 +248,7 @@ function isRoot(dir: string) {
* @returns STDOUT (if successful).
*/
async function execute(cmd: string, ...args: string[]) {
const child = spawn(cmd, args, { stdio: [ 'ignore', 'pipe', 'inherit' ] });
const child = spawn(cmd, args, { shell: true, stdio: [ 'ignore', 'pipe', 'inherit' ] });
let stdout = '';
child.stdout.on('data', chunk => stdout += chunk.toString());
return new Promise<string>((ok, fail) => {
7 changes: 7 additions & 0 deletions tools/y-npm/bin/.y-npm.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\y-npm\bin\y-npm" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\y-npm\bin\y-npm" %*
)
2 changes: 1 addition & 1 deletion tools/y-npm/lib/run-npm-command.ts
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ export function runCommand(command: string, args: string[], additionalEnv?: Node
env[key] = value;
}
}
const child = spawn(command, args, { detached: false, env, stdio: ['inherit', 'pipe', 'pipe'] });
const child = spawn(command, args, { detached: false, env, shell: true, stdio: ['inherit', 'pipe', 'pipe'] });
debug(`Command PID: ${child.pid}`);
const stdout = new Array<Buffer>();
const stderr = new Array<Buffer>();

0 comments on commit c269d8a

Please sign in to comment.