@@ -4,10 +4,16 @@ import {join} from 'path';
4
4
import { green , red } from 'chalk' ;
5
5
import { releasePackages } from './publish' ;
6
6
import { sync as glob } from 'glob' ;
7
+ import { spawnSync } from 'child_process' ;
7
8
import { buildConfig , sequenceTask } from 'material2-build-tools' ;
8
9
10
+ const { projectDir, projectVersion, outputDir} = buildConfig ;
11
+
12
+ /** Git repository URL that has been read out from the package.json file. */
13
+ const repositoryGitUrl = require ( '../../../package.json' ) . repository . url ;
14
+
9
15
/** Path to the directory where all releases are created. */
10
- const releasesDir = join ( buildConfig . outputDir , 'releases' ) ;
16
+ const releasesDir = join ( outputDir , 'releases' ) ;
11
17
12
18
/** RegExp that matches Angular component inline styles that contain a sourcemap reference. */
13
19
const 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): *["'[]/;
17
23
18
24
task ( 'validate-release' , sequenceTask ( ':publish:build-releases' , 'validate-release:check-bundles' ) ) ;
19
25
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
+
20
38
/** Task that checks the release bundles for any common mistakes before releasing to the public. */
21
39
task ( 'validate-release:check-bundles' , ( ) => {
22
40
const releaseFailures = releasePackages
0 commit comments