@@ -16,50 +16,50 @@ import { Schema } from './schema';
1616// createJobHandler() but add typings specific to Architect Builders.
1717export default createBuilder < any > (
1818 async ( options : Schema , context : BuilderContext ) : Promise < BuilderOutput > => {
19- // The project root is added to a BuilderContext.
20- const root = normalize ( context . workspaceRoot ) ;
21- const workspace = new experimental . workspace . Workspace (
22- root ,
23- new NodeJsSyncHost ( )
24- ) ;
25- await workspace
26- . loadWorkspaceFromHost ( normalize ( 'angular.json' ) )
27- . toPromise ( ) ;
19+ try {
20+ // The project root is added to a BuilderContext.
21+ const root = normalize ( context . workspaceRoot ) ;
22+ const workspace = new experimental . workspace . Workspace (
23+ root ,
24+ new NodeJsSyncHost ( )
25+ ) ;
26+ await workspace
27+ . loadWorkspaceFromHost ( normalize ( 'angular.json' ) )
28+ . toPromise ( ) ;
2829
29- if ( ! context . target ) {
30- throw new Error ( 'Cannot deploy the application without a target' ) ;
31- }
30+ if ( ! context . target ) {
31+ throw new Error ( 'Cannot deploy the application without a target' ) ;
32+ }
3233
33- const targets = workspace . getProjectTargets ( context . target . project ) ;
34+ const targets = workspace . getProjectTargets ( context . target . project ) ;
3435
35- if (
36- ! targets ||
37- ! targets . build ||
38- ! targets . build . options ||
39- ! targets . build . options . outputPath
40- ) {
41- throw new Error ( 'Cannot find the project output directory' ) ;
42- }
36+ if (
37+ ! targets ||
38+ ! targets . build ||
39+ ! targets . build . options ||
40+ ! targets . build . options . outputPath
41+ ) {
42+ throw new Error ( 'Cannot find the project output directory' ) ;
43+ }
4344
44- // normalizes pathes don't work with all native functions
45- // as a workaround, you can use the following 2 lines
46- const isWin = os . platform ( ) === 'win32' ;
47- const workspaceRoot = ! isWin
48- ? workspace . root
49- : asWindowsPath ( workspace . root ) ;
50- // if this is not necessary, use this:
51- // const workspaceRoot = workspace.root;
45+ // normalizes pathes don't work with all native functions
46+ // as a workaround, you can use the following 2 lines
47+ const isWin = os . platform ( ) === 'win32' ;
48+ const workspaceRoot = ! isWin
49+ ? workspace . root
50+ : asWindowsPath ( workspace . root ) ;
51+ // if this is not necessary, use this:
52+ // const workspaceRoot = workspace.root;
5253
53- try {
5454 await deploy (
5555 engine ,
5656 context ,
5757 path . join ( workspaceRoot , targets . build . options . outputPath ) ,
5858 options
5959 ) ;
6060 } catch ( e ) {
61- context . logger . error ( 'Error when trying to deploy:' , e ) ;
62- console . error ( e ) ;
61+ context . logger . error ( '❌ An error occurred when trying to deploy:' ) ;
62+ context . logger . error ( e . message ) ;
6363 return { success : false } ;
6464 }
6565
0 commit comments