@@ -11,6 +11,7 @@ import * as rimraf from "rimraf";
1111import * as AdmZip from "adm-zip" ;
1212import * as async from "async" ;
1313import * as mkdirp from "mkdirp" ;
14+ import { getBundledDCDUrl , nightlyReleaseId } from "./_bundled_versions" ;
1415
1516function gitPath ( ) {
1617 return vscode . workspace . getConfiguration ( "git" ) . get ( "path" , "git" ) || "git" ;
@@ -117,7 +118,6 @@ export interface Release {
117118 asset ?: ReleaseAsset ;
118119}
119120
120- const nightlyReleaseId = 20717582 ;
121121const servedVersionCache = {
122122 release : < Release | undefined > undefined ,
123123 channel : "" ,
@@ -273,14 +273,14 @@ function findFirstMatchingAsset(name: string | "nightly", assets: ReleaseAsset[]
273273 for ( let i = 0 ; i < assets . length ; i ++ ) {
274274 const asset = assets [ i ] ;
275275 let test = asset . name ;
276- if ( test . startsWith ( "serve-d" ) ) test = test . substr ( "serve-d" . length ) ;
277- if ( test . startsWith ( "-" ) || test . startsWith ( "_" ) ) test = test . substr ( 1 ) ;
276+ if ( test . startsWith ( "serve-d" ) ) test = test . substring ( "serve-d" . length ) ;
277+ if ( test . startsWith ( "-" ) || test . startsWith ( "_" ) ) test = test . substring ( 1 ) ;
278278
279279 if ( ! test . startsWith ( os ) ) continue ;
280- test = test . substr ( os . length ) ;
281- if ( test . startsWith ( "-" ) || test . startsWith ( "_" ) ) test = test . substr ( 1 ) ;
282- if ( test . startsWith ( "nightly" ) ) test = test . substr ( "nightly" . length ) ;
283- if ( test . startsWith ( "-" ) || test . startsWith ( "_" ) ) test = test . substr ( 1 ) ;
280+ test = test . substring ( os . length ) ;
281+ if ( test . startsWith ( "-" ) || test . startsWith ( "_" ) ) test = test . substring ( 1 ) ;
282+ if ( test . startsWith ( "nightly" ) ) test = test . substring ( "nightly" . length ) ;
283+ if ( test . startsWith ( "-" ) || test . startsWith ( "_" ) ) test = test . substring ( 1 ) ;
284284
285285 // remaining:
286286 // either x86_64-20191017-4b5427.tar.xz
@@ -291,18 +291,18 @@ function findFirstMatchingAsset(name: string | "nightly", assets: ReleaseAsset[]
291291 }
292292 return undefined ;
293293 } else {
294- if ( name . startsWith ( "v" ) ) name = name . substr ( 1 ) ;
294+ if ( name . startsWith ( "v" ) ) name = name . substring ( 1 ) ;
295295
296296 for ( let i = 0 ; i < assets . length ; i ++ ) {
297297 const asset = assets [ i ] ;
298298 let test = asset . name ;
299- if ( test . startsWith ( "serve-d" ) ) test = test . substr ( "serve-d" . length ) ;
300- if ( test . startsWith ( "-" ) || test . startsWith ( "_" ) ) test = test . substr ( 1 ) ;
301- if ( test . startsWith ( name ) ) test = test . substr ( name . length ) ;
302- if ( test . startsWith ( "-" ) || test . startsWith ( "_" ) ) test = test . substr ( 1 ) ;
299+ if ( test . startsWith ( "serve-d" ) ) test = test . substring ( "serve-d" . length ) ;
300+ if ( test . startsWith ( "-" ) || test . startsWith ( "_" ) ) test = test . substring ( 1 ) ;
301+ if ( test . startsWith ( name ) ) test = test . substring ( name . length ) ;
302+ if ( test . startsWith ( "-" ) || test . startsWith ( "_" ) ) test = test . substring ( 1 ) ;
303303
304304 const dot = test . indexOf ( "." ) ;
305- if ( dot != - 1 ) test = test . substr ( 0 , dot ) ;
305+ if ( dot != - 1 ) test = test . substring ( 0 , dot ) ;
306306
307307 if ( test == `${ os } -${ arch } ` || test == os ) return asset ;
308308 }
@@ -362,33 +362,8 @@ export function installServeD(
362362 } ;
363363
364364 // add DCD binaries here as well
365- if ( process . platform == "linux" && process . arch == "x64" ) {
366- urls . push ( {
367- url : "https://github.com/dlang-community/DCD/releases/download/v0.15.2/dcd-v0.15.2-linux-x86_64.tar.gz" ,
368- title : "DCD" ,
369- } ) ;
370- } else if ( process . platform == "darwin" && process . arch == "x64" ) {
371- urls . push ( {
372- url : "https://github.com/dlang-community/DCD/releases/download/v0.15.2/dcd-v0.15.2-osx-x86_64.tar.gz" ,
373- title : "DCD" ,
374- } ) ;
375- } else if ( process . platform == "darwin" && process . arch == "arm64" ) {
376- urls . push ( {
377- url : "https://github.com/dlang-community/DCD/releases/download/v0.15.2/dcd-v0.15.2-osx-arm64.tar.gz" ,
378- title : "DCD" ,
379- } ) ;
380- } else if ( process . platform == "win32" ) {
381- if ( process . arch == "x64" )
382- urls . push ( {
383- url : "https://github.com/dlang-community/DCD/releases/download/v0.15.2/dcd-v0.15.2-windows-x86_64.zip" ,
384- title : "DCD" ,
385- } ) ;
386- else
387- urls . push ( {
388- url : "https://github.com/dlang-community/DCD/releases/download/v0.15.2/dcd-v0.15.2-windows-x86.zip" ,
389- title : "DCD" ,
390- } ) ;
391- }
365+ const bundledDCD = getBundledDCDUrl ( ) ;
366+ if ( bundledDCD ) urls . push ( { url : bundledDCD , title : "DCD" } ) ;
392367
393368 return ( env : NodeJS . ProcessEnv ) =>
394369 new Promise ( ( done ) => {
0 commit comments