-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert(init-templates): csharp and fsharp app init fails when path co…
- Loading branch information
Showing
7 changed files
with
137 additions
and
99 deletions.
There are no files selected for viewing
32 changes: 26 additions & 6 deletions
32
packages/aws-cdk/lib/init-templates/app/csharp/add-project.hook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
import * as child_process from 'child_process'; | ||
import * as path from 'path'; | ||
import { InvokeHook } from '../../../init'; | ||
import { shell } from '../../../os'; | ||
|
||
export const invoke: InvokeHook = async (targetDirectory: string) => { | ||
const slnPath = path.join(targetDirectory, 'src', '%name.PascalCased%.sln'); | ||
const csprojPath = path.join(targetDirectory, 'src', '%name.PascalCased%', '%name.PascalCased%.csproj'); | ||
try { | ||
await shell(['dotnet', 'sln', slnPath, 'add', csprojPath]); | ||
} catch (e) { | ||
throw new Error(`Could not add project %name.PascalCased%.csproj to solution %name.PascalCased%.sln. ${e.message}`); | ||
} | ||
|
||
const child = child_process.spawn('dotnet', ['sln', slnPath, 'add', csprojPath], { | ||
// Need this for Windows where we want .cmd and .bat to be found as well. | ||
shell: true, | ||
stdio: ['ignore', 'pipe', 'inherit'], | ||
}); | ||
|
||
await new Promise<string>((resolve, reject) => { | ||
const stdout = new Array<any>(); | ||
|
||
child.stdout.on('data', chunk => { | ||
process.stdout.write(chunk); | ||
stdout.push(chunk); | ||
}); | ||
|
||
child.once('error', reject); | ||
|
||
child.once('exit', code => { | ||
if (code === 0) { | ||
resolve(Buffer.concat(stdout).toString('utf-8')); | ||
} else { | ||
reject(new Error(`Could not add project %name.PascalCased%.csproj to solution %name.PascalCased%.sln. Error code: ${code}`)); | ||
} | ||
}); | ||
}); | ||
}; |
32 changes: 26 additions & 6 deletions
32
packages/aws-cdk/lib/init-templates/app/fsharp/add-project.hook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
import * as child_process from 'child_process'; | ||
import * as path from 'path'; | ||
import { InvokeHook } from '../../../init'; | ||
import { shell } from '../../../os'; | ||
|
||
export const invoke: InvokeHook = async (targetDirectory: string) => { | ||
const slnPath = path.join(targetDirectory, 'src', '%name.PascalCased%.sln'); | ||
const fsprojPath = path.join(targetDirectory, 'src', '%name.PascalCased%', '%name.PascalCased%.fsproj'); | ||
try { | ||
await shell(['dotnet', 'sln', slnPath, 'add', fsprojPath]); | ||
} catch (e) { | ||
throw new Error(`Could not add project %name.PascalCased%.fsproj to solution %name.PascalCased%.sln. ${e.message}`); | ||
} | ||
|
||
const child = child_process.spawn('dotnet', ['sln', slnPath, 'add', fsprojPath], { | ||
// Need this for Windows where we want .cmd and .bat to be found as well. | ||
shell: true, | ||
stdio: ['ignore', 'pipe', 'inherit'], | ||
}); | ||
|
||
await new Promise<string>((resolve, reject) => { | ||
const stdout = new Array<any>(); | ||
|
||
child.stdout.on('data', chunk => { | ||
process.stdout.write(chunk); | ||
stdout.push(chunk); | ||
}); | ||
|
||
child.once('error', reject); | ||
|
||
child.once('exit', code => { | ||
if (code === 0) { | ||
resolve(Buffer.concat(stdout).toString('utf-8')); | ||
} else { | ||
reject(new Error(`Could not add project %name.PascalCased%.fsproj to solution %name.PascalCased%.sln. Error code: ${code}`)); | ||
} | ||
}); | ||
}); | ||
}; |
32 changes: 26 additions & 6 deletions
32
packages/aws-cdk/lib/init-templates/sample-app/csharp/add-project.hook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
import * as child_process from 'child_process'; | ||
import * as path from 'path'; | ||
import { InvokeHook } from '../../../init'; | ||
import { shell } from '../../../os'; | ||
|
||
export const invoke: InvokeHook = async (targetDirectory: string) => { | ||
const slnPath = path.join(targetDirectory, 'src', '%name.PascalCased%.sln'); | ||
const csprojPath = path.join(targetDirectory, 'src', '%name.PascalCased%', '%name.PascalCased%.csproj'); | ||
try { | ||
await shell(['dotnet', 'sln', slnPath, 'add', csprojPath]); | ||
} catch (e) { | ||
throw new Error(`Could not add project %name.PascalCased%.csproj to solution %name.PascalCased%.sln. ${e.message}`); | ||
} | ||
|
||
const child = child_process.spawn('dotnet', ['sln', slnPath, 'add', csprojPath], { | ||
// Need this for Windows where we want .cmd and .bat to be found as well. | ||
shell: true, | ||
stdio: ['ignore', 'pipe', 'inherit'], | ||
}); | ||
|
||
await new Promise<string>((resolve, reject) => { | ||
const stdout = new Array<any>(); | ||
|
||
child.stdout.on('data', chunk => { | ||
process.stdout.write(chunk); | ||
stdout.push(chunk); | ||
}); | ||
|
||
child.once('error', reject); | ||
|
||
child.once('exit', code => { | ||
if (code === 0) { | ||
resolve(Buffer.concat(stdout).toString('utf-8')); | ||
} else { | ||
reject(new Error(`Could not add project %name.PascalCased%.csproj to solution %name.PascalCased%.sln. Error code: ${code}`)); | ||
} | ||
}); | ||
}); | ||
}; |
32 changes: 26 additions & 6 deletions
32
packages/aws-cdk/lib/init-templates/sample-app/fsharp/add-project.hook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
import * as child_process from 'child_process'; | ||
import * as path from 'path'; | ||
import { InvokeHook } from '../../../init'; | ||
import { shell } from '../../../os'; | ||
|
||
export const invoke: InvokeHook = async (targetDirectory: string) => { | ||
const slnPath = path.join(targetDirectory, 'src', '%name.PascalCased%.sln'); | ||
const fsprojPath = path.join(targetDirectory, 'src', '%name.PascalCased%', '%name.PascalCased%.fsproj'); | ||
try { | ||
await shell(['dotnet', 'sln', slnPath, 'add', fsprojPath]); | ||
} catch (e) { | ||
throw new Error(`Could not add project %name.PascalCased%.fsproj to solution %name.PascalCased%.sln. ${e.message}`); | ||
} | ||
|
||
const child = child_process.spawn('dotnet', ['sln', slnPath, 'add', fsprojPath], { | ||
// Need this for Windows where we want .cmd and .bat to be found as well. | ||
shell: true, | ||
stdio: ['ignore', 'pipe', 'inherit'], | ||
}); | ||
|
||
await new Promise<string>((resolve, reject) => { | ||
const stdout = new Array<any>(); | ||
|
||
child.stdout.on('data', chunk => { | ||
process.stdout.write(chunk); | ||
stdout.push(chunk); | ||
}); | ||
|
||
child.once('error', reject); | ||
|
||
child.once('exit', code => { | ||
if (code === 0) { | ||
resolve(Buffer.concat(stdout).toString('utf-8')); | ||
} else { | ||
reject(new Error(`Could not add project %name.PascalCased%.fsproj to solution %name.PascalCased%.sln. Error code: ${code}`)); | ||
} | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters