4
4
* @copyright jQuery Foundation and other contributors, https://jquery.org/
5
5
* MIT License
6
6
*/
7
- /* global cat, cp, echo, exec, exit, find, mkdir, mv, rm, target, test */
7
+ /* global echo, exit, find, target */
8
8
9
9
"use strict" ;
10
10
16
16
require ( "shelljs/make" ) ;
17
17
18
18
var checker = require ( "npm-license" ) ,
19
- dateformat = require ( "dateformat" ) ,
20
- nodeCLI = require ( "shelljs-nodecli" ) ,
21
- semver = require ( "semver" ) ;
19
+ nodeCLI = require ( "shelljs-nodecli" ) ;
22
20
23
21
//------------------------------------------------------------------------------
24
22
// Settings
@@ -33,16 +31,14 @@ var OPEN_SOURCE_LICENSES = [
33
31
//------------------------------------------------------------------------------
34
32
35
33
var NODE_MODULES = "./node_modules/" ,
36
- TEMP_DIR = "./tmp/" ,
37
- BUILD_DIR = "./build/" ,
38
34
39
35
// Utilities - intentional extra space at the end of each string
40
36
MOCHA = NODE_MODULES + "mocha/bin/_mocha " ,
41
37
42
38
// Files
43
39
MAKEFILE = "./Makefile.js" ,
44
40
/* 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" ,
46
42
TEST_FILES = find ( "tests/lib/" ) . filter ( fileType ( "js" ) ) . join ( " " ) ;
47
43
/* eslint-enable no-use-before-define */
48
44
@@ -62,64 +58,6 @@ function fileType(extension) {
62
58
} ;
63
59
}
64
60
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
-
123
61
//------------------------------------------------------------------------------
124
62
// Tasks
125
63
//------------------------------------------------------------------------------
@@ -180,60 +118,6 @@ target.docs = function() {
180
118
echo ( "Documentation has been output to /jsdoc" ) ;
181
119
} ;
182
120
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
-
237
121
target . checkLicenses = function ( ) {
238
122
239
123
/**
@@ -283,15 +167,3 @@ target.checkLicenses = function() {
283
167
}
284
168
} ) ;
285
169
} ;
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