@@ -9,43 +9,43 @@ const exec = util.promisify( nodeExec );
99const pkg = JSON . parse ( await fs . readFile ( "./package.json" , "utf8" ) ) ;
1010
1111async function isCleanWorkingDir ( ) {
12- const { stdout } = await exec ( "git status --untracked-files=no --porcelain" ) ;
13- return ! stdout . trim ( ) ;
12+ const { stdout } = await exec ( "git status --untracked-files=no --porcelain" ) ;
13+ return ! stdout . trim ( ) ;
1414}
1515
1616async function versionForDist ( { srcPath, destPath, version } ) {
17- const code = await fs . readFile ( srcPath , "utf8" ) ;
18- const compiledContents = code . replace ( / @ V E R S I O N / g, version ) ;
17+ const code = await fs . readFile ( srcPath , "utf8" ) ;
18+ const compiledContents = code . replace ( / @ V E R S I O N / g, version ) ;
1919
20- await fs . mkdir ( path . dirname ( destPath ) , { recursive : true } ) ;
21- await fs . writeFile ( destPath , compiledContents ) ;
22- console . log ( `${ destPath } v${ version } created.` ) ;
20+ await fs . mkdir ( path . dirname ( destPath ) , { recursive : true } ) ;
21+ await fs . writeFile ( destPath , compiledContents ) ;
22+ console . log ( `${ destPath } v${ version } created.` ) ;
2323}
2424
2525export async function build ( { version = process . env . VERSION } = { } ) {
2626
27- // Add the short commit hash to the version string
28- // when the version is not for a release.
29- if ( ! version ) {
30- const { stdout } = await exec ( "git rev-parse --short HEAD" ) ;
31- const isClean = await isCleanWorkingDir ( ) ;
32-
33- // "+SHA" is semantically correct
34- // Add ".dirty" as well if the working dir is not clean
35- version = `${ pkg . version } +${ stdout . trim ( ) } ${
36- isClean ? "" : ".dirty"
37- } `;
38- }
39-
40- await versionForDist ( {
41- srcPath : "src/jquery.mousewheel.js" ,
42- destPath : "dist/jquery.mousewheel.js" ,
43- version
44- } ) ;
45-
46- await minify ( {
47- srcPath : "dist/jquery.mousewheel.js" ,
48- destPath : "dist/jquery.mousewheel.min.js" ,
49- version
50- } ) ;
27+ // Add the short commit hash to the version string
28+ // when the version is not for a release.
29+ if ( ! version ) {
30+ const { stdout } = await exec ( "git rev-parse --short HEAD" ) ;
31+ const isClean = await isCleanWorkingDir ( ) ;
32+
33+ // "+SHA" is semantically correct
34+ // Add ".dirty" as well if the working dir is not clean
35+ version = `${ pkg . version } +${ stdout . trim ( ) } ${
36+ isClean ? "" : ".dirty"
37+ } `;
38+ }
39+
40+ await versionForDist ( {
41+ srcPath : "src/jquery.mousewheel.js" ,
42+ destPath : "dist/jquery.mousewheel.js" ,
43+ version
44+ } ) ;
45+
46+ await minify ( {
47+ srcPath : "dist/jquery.mousewheel.js" ,
48+ destPath : "dist/jquery.mousewheel.min.js" ,
49+ version
50+ } ) ;
5151}
0 commit comments