| 49 | } |
| 50 | |
| 51 | function updatePath() { |
| 52 | const input = es.through(); |
| 53 | const output = input.pipe( |
| 54 | es.mapSync((f) => { |
| 55 | const contents = f.contents.toString('utf8'); |
| 56 | const filePath = f.path; |
| 57 | let platformRelativepath = path.relative( |
| 58 | path.dirname(filePath), |
| 59 | path.resolve(process.cwd(), 'out/src/platform/node'), |
| 60 | ); |
| 61 | platformRelativepath = platformRelativepath.replace(/\\/g, '/'); |
| 62 | f.contents = Buffer.from( |
| 63 | contents.replace( |
| 64 | /\(\"platform\/([^"]*)\"\)/g, |
| 65 | '("' + (platformRelativepath === '' ? './' : platformRelativepath + '/') + '$1")', |
| 66 | ), |
| 67 | 'utf8', |
| 68 | ); |
| 69 | return f; |
| 70 | }), |
| 71 | ); |
| 72 | return es.duplex(input, output); |
| 73 | } |
| 74 | |
| 75 | function copyPackageJson() { |
| 76 | return gulp.src('./package.json').pipe(gulp.dest('out')); |