@@ -4,12 +4,7 @@ const readline = require('readline');
44const fse = require ( 'fs-extra' ) ;
55const exec = require ( 'child_process' ) . exec ;
66const through = require ( 'through2' ) ;
7- const {
8- dataDir,
9- constants,
10- dataToolImage,
11- osmPreprocessingURLs,
12- } = require ( '../config' ) ;
7+ const { dataDir, constants, dataToolImage } = require ( '../config' ) ;
138const { postSlackMessage, createDir } = require ( '../util' ) ;
149
1510async function readPreprocessingInstructions ( preprocessingInstructionsFile ) {
@@ -45,19 +40,23 @@ async function readPreprocessingInstructions(preprocessingInstructionsFile) {
4540function preprocessWithFile (
4641 osmFile ,
4742 quiet = false ,
48- osmPreprocessingDlDir ,
43+ osmPreprocessingDir ,
4944 osmId ,
5045 osmFileName ,
5146) {
5247 const lastLog = [ ] ;
5348
5449 return new Promise ( ( resolve , reject ) => {
55- const preprocessingInstructionsFile = `${ osmPreprocessingDlDir } /${ osmId } .txt` ;
50+ const preprocessingInstructionsFile = `${ osmPreprocessingDir } /${ osmId } .txt` ;
5651
5752 if ( ! fs . existsSync ( osmFile ) ) {
5853 reject ( new Error ( `${ osmFile } does not exist!\n` ) ) ;
5954 } else if ( ! fs . existsSync ( preprocessingInstructionsFile ) ) {
60- reject ( new Error ( `${ preprocessingInstructionsFile } does not exist!\n` ) ) ;
55+ reject (
56+ new Error (
57+ `No OSM preprocessing instructions for ${ osmId } . ${ preprocessingInstructionsFile } does not exist!\n` ,
58+ ) ,
59+ ) ;
6160 } else {
6261 createDir ( `${ dataDir } /tmp` ) ;
6362 fs . mkdtemp ( `${ dataDir } /tmp/osm-preprocessing` , ( err , folder ) => {
@@ -138,7 +137,7 @@ function preprocessWithFile(
138137}
139138
140139module . exports = {
141- runOSMPreprocessing : osmPreprocessingDlDir => {
140+ runOSMPreprocessing : osmPreprocessingDir => {
142141 return through . obj ( function ( file , encoding , callback ) {
143142 const osmFile = file . history [ file . history . length - 1 ] ;
144143 if ( process . env . SKIP_OSM_PREPROCESSING ) {
@@ -150,19 +149,7 @@ module.exports = {
150149 const osmFileName = osmFile . split ( '/' ) . pop ( ) ;
151150 // This can be, for example, hsl, finland, or southFinland.
152151 const osmId = osmFileName . split ( '.' ) [ 0 ] ;
153- if ( ! osmPreprocessingURLs [ osmId ] ) {
154- process . stdout . write (
155- 'No OSM preprocessing instructions for ' + osmId + '\n' ,
156- ) ;
157- return callback ( null , file ) ;
158- }
159- preprocessWithFile (
160- osmFile ,
161- true ,
162- osmPreprocessingDlDir ,
163- osmId ,
164- osmFileName ,
165- )
152+ preprocessWithFile ( osmFile , true , osmPreprocessingDir , osmId , osmFileName )
166153 . then ( outputContents => {
167154 if ( outputContents ) {
168155 file . contents = outputContents ;
@@ -171,7 +158,8 @@ module.exports = {
171158 callback ( null , null ) ;
172159 }
173160 } )
174- . catch ( ( ) => {
161+ . catch ( err => {
162+ process . stdout . write ( err . message ) ;
175163 callback ( null , null ) ;
176164 } ) ;
177165 } ) ;
0 commit comments