@@ -4,10 +4,16 @@ import {join} from 'path';
44import { green , red } from 'chalk' ;
55import { releasePackages } from './publish' ;
66import { sync as glob } from 'glob' ;
7+ import { spawnSync } from 'child_process' ;
78import { buildConfig , sequenceTask } from 'material2-build-tools' ;
89
10+ const { projectDir, projectVersion, outputDir} = buildConfig ;
11+
12+ /** Git repository URL that has been read out from the project package.json file. */
13+ const repositoryGitUrl = require ( '../../../package.json' ) . repository . url ;
14+
915/** Path to the directory where all releases are created. */
10- const releasesDir = join ( buildConfig . outputDir , 'releases' ) ;
16+ const releasesDir = join ( outputDir , 'releases' ) ;
1117
1218/** RegExp that matches Angular component inline styles that contain a sourcemap reference. */
1319const inlineStylesSourcemapRegex = / s t y l e s : ? \[ [ " ' ] .* s o u r c e M a p p i n g U R L = .* [ " ' ] / ;
@@ -17,6 +23,18 @@ const externalReferencesRegex = /(templateUrl|styleUrls): *["'[]/;
1723
1824task ( 'validate-release' , sequenceTask ( ':publish:build-releases' , 'validate-release:check-bundles' ) ) ;
1925
26+ task ( 'validate-release:check-remote-tag' , ( ) => {
27+ // Since we cannot assume that every developer uses `origin` as the default name for the upstream
28+ // remote, we just pass in the Git URL that refers to angular/material2 repository on Github.
29+ const tagCommitSha = spawnSync ( 'git' , [ 'ls-remote' , '--tags' , repositoryGitUrl , projectVersion ] ,
30+ { cwd : projectDir } ) . stdout . toString ( ) . trim ( ) ;
31+
32+ if ( ! tagCommitSha ) {
33+ throw Error ( red ( `Cannot publish v${ projectVersion } because the release is not ` +
34+ `tagged on upstream yet. Please tag the release before publishing to NPM.` ) ) ;
35+ }
36+ } ) ;
37+
2038/** Task that checks the release bundles for any common mistakes before releasing to the public. */
2139task ( 'validate-release:check-bundles' , ( ) => {
2240 const releaseFailures = releasePackages
0 commit comments