44 * @copyright jQuery Foundation and other contributors, https://jquery.org/
55 * MIT License
66 */
7- /* global cat, cp, echo, exec, exit, find, mkdir, mv, rm, target, test */
7+ /* global echo, exit, find, target */
88
99"use strict" ;
1010
1616require ( "shelljs/make" ) ;
1717
1818var checker = require ( "npm-license" ) ,
19- dateformat = require ( "dateformat" ) ,
20- nodeCLI = require ( "shelljs-nodecli" ) ,
21- semver = require ( "semver" ) ;
19+ nodeCLI = require ( "shelljs-nodecli" ) ;
2220
2321//------------------------------------------------------------------------------
2422// Settings
@@ -33,16 +31,14 @@ var OPEN_SOURCE_LICENSES = [
3331//------------------------------------------------------------------------------
3432
3533var NODE_MODULES = "./node_modules/" ,
36- TEMP_DIR = "./tmp/" ,
37- BUILD_DIR = "./build/" ,
3834
3935 // Utilities - intentional extra space at the end of each string
4036 MOCHA = NODE_MODULES + "mocha/bin/_mocha " ,
4137
4238 // Files
4339 MAKEFILE = "./Makefile.js" ,
4440 /* eslint-disable no-use-before-define */
45- JS_FILES = find ( "lib/" ) . filter ( fileType ( "js" ) ) . join ( " " ) + " espree .js" ,
41+ JS_FILES = find ( "lib/" ) . filter ( fileType ( "js" ) ) . join ( " " ) + " parser .js" ,
4642 TEST_FILES = find ( "tests/lib/" ) . filter ( fileType ( "js" ) ) . join ( " " ) ;
4743 /* eslint-enable no-use-before-define */
4844
@@ -62,64 +58,6 @@ function fileType(extension) {
6258 } ;
6359}
6460
65- /**
66- * Executes a command and returns the output instead of printing it to stdout.
67- * @param {string } cmd The command string to execute.
68- * @returns {string } The result of the executed command.
69- */
70- function execSilent ( cmd ) {
71- return exec ( cmd , { silent : true } ) . output ;
72- }
73-
74- /**
75- * Creates a release version tag and pushes to origin.
76- * @param {string } type The type of release to do (patch, minor, major)
77- * @returns {void }
78- */
79- function release ( type ) {
80- var newVersion ;
81-
82- target . test ( ) ;
83- newVersion = execSilent ( "npm version " + type ) . trim ( ) ;
84- target . changelog ( ) ;
85-
86- // add changelog to commit
87- exec ( "git add CHANGELOG.md" ) ;
88- exec ( "git commit --amend --no-edit" ) ;
89-
90- // replace existing tag
91- exec ( "git tag -f " + newVersion ) ;
92-
93- // push all the things
94- exec ( "git push origin master --tags" ) ;
95- exec ( "npm publish" ) ;
96- }
97-
98-
99- /**
100- * Splits a command result to separate lines.
101- * @param {string } result The command result string.
102- * @returns {array } The separated lines.
103- */
104- function splitCommandResultToLines ( result ) {
105- return result . trim ( ) . split ( "\n" ) ;
106- }
107-
108- /**
109- * Returns a list of sorted, valid semtantic-verisioning git tags
110- * @returns {string[] } The version tags
111- */
112- function getVersionTags ( ) {
113- var tags = splitCommandResultToLines ( exec ( "git tag" , { silent : true } ) . output ) ;
114-
115- return tags . reduce ( function ( list , tag ) {
116- if ( semver . valid ( tag ) ) {
117- list . push ( tag ) ;
118- }
119- return list ;
120- } , [ ] ) . sort ( semver . compare ) ;
121- }
122-
12361//------------------------------------------------------------------------------
12462// Tasks
12563//------------------------------------------------------------------------------
@@ -180,60 +118,6 @@ target.docs = function() {
180118 echo ( "Documentation has been output to /jsdoc" ) ;
181119} ;
182120
183- target . browserify = function ( ) {
184-
185- // 1. create temp and build directory
186- if ( ! test ( "-d" , TEMP_DIR ) ) {
187- mkdir ( TEMP_DIR ) ;
188- mkdir ( TEMP_DIR + "/lib" ) ;
189- }
190-
191- if ( ! test ( "-d" , BUILD_DIR ) ) {
192- mkdir ( BUILD_DIR ) ;
193- }
194-
195- // 2. copy files into temp directory
196- cp ( "-r" , "lib/*" , TEMP_DIR + "/lib" ) ;
197- cp ( "espree.js" , TEMP_DIR ) ;
198- cp ( "package.json" , TEMP_DIR ) ;
199-
200-
201- // 3. browserify the temp directory
202- nodeCLI . exec ( "browserify" , TEMP_DIR + "espree.js" , "-o" , BUILD_DIR + "espree.js" , "-s espree" ) ;
203-
204- // 4. remove temp directory
205- rm ( "-r" , TEMP_DIR ) ;
206- } ;
207-
208- target . changelog = function ( ) {
209-
210- // get most recent two tags
211- var tags = getVersionTags ( ) ,
212- rangeTags = tags . slice ( tags . length - 2 ) ,
213- now = new Date ( ) ,
214- timestamp = dateformat ( now , "mmmm d, yyyy" ) ;
215-
216- // output header
217- ( rangeTags [ 1 ] + " - " + timestamp + "\n" ) . to ( "CHANGELOG.tmp" ) ;
218-
219- // get log statements
220- var logs = exec ( "git log --pretty=format:\"* %s (%an)\" " + rangeTags . join ( ".." ) , { silent : true } ) . output . split ( / \n / g) ;
221- logs = logs . filter ( function ( line ) {
222- return line . indexOf ( "Merge pull request" ) === - 1 && line . indexOf ( "Merge branch" ) === - 1 ;
223- } ) ;
224- logs . push ( "" ) ; // to create empty lines
225- logs . unshift ( "" ) ;
226-
227- // output log statements
228- logs . join ( "\n" ) . toEnd ( "CHANGELOG.tmp" ) ;
229-
230- // switch-o change-o
231- cat ( "CHANGELOG.tmp" , "CHANGELOG.md" ) . to ( "CHANGELOG.md.tmp" ) ;
232- rm ( "CHANGELOG.tmp" ) ;
233- rm ( "CHANGELOG.md" ) ;
234- mv ( "CHANGELOG.md.tmp" , "CHANGELOG.md" ) ;
235- } ;
236-
237121target . checkLicenses = function ( ) {
238122
239123 /**
@@ -283,15 +167,3 @@ target.checkLicenses = function() {
283167 }
284168 } ) ;
285169} ;
286-
287- target . patch = function ( ) {
288- release ( "patch" ) ;
289- } ;
290-
291- target . minor = function ( ) {
292- release ( "minor" ) ;
293- } ;
294-
295- target . major = function ( ) {
296- release ( "major" ) ;
297- } ;
0 commit comments