From c770f9f4fe6a5519fe9f8db1f04b2e790cd31206 Mon Sep 17 00:00:00 2001 From: tdzl2003 Date: Wed, 6 Apr 2016 13:34:52 +0800 Subject: [PATCH] Bugfix: intermedia doesn't clear up between bundles. --- local-cli/src/bundle.js | 17 +++++++++++++++-- package.json | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/local-cli/src/bundle.js b/local-cli/src/bundle.js index c10be3b..26a38dc 100644 --- a/local-cli/src/bundle.js +++ b/local-cli/src/bundle.js @@ -4,6 +4,7 @@ import * as path from 'path'; import { mkdir as mkdirRecurisve } from 'mkdir-recursive'; +import rmdirRecursive from 'rimraf'; import { getRNVersion, translateOptions, @@ -28,6 +29,18 @@ function mkdir(dir){ }); } +function rmdir(dir) { + return new Promise((resolve, reject) => { + rmdirRecursive(dir, err => { + if (err) { + reject(err); + } else { + resolve(); + } + }); + }); +} + async function pack(dir, output){ await mkdir(path.dirname(output)); await new Promise((resolve, reject) => { @@ -199,6 +212,7 @@ async function diffWithPPK(origin, next, output) { for (var k in originEntries) { if (!newEntries[k]) { + console.log('Delete '+k); deletes[k] = 1; } } @@ -332,12 +346,11 @@ export const commands = { throw new Error('Platform must be specified.'); } - await mkdir(intermediaDir); - const { version, major, minor } = getRNVersion(); console.log('Bundling with React Native version: ', version); + await rmdir(intermediaDir); await mkdir(intermediaDir); require(path.resolve('node_modules/react-native/packager/babelRegisterOnly'))([ diff --git a/package.json b/package.json index 4357e5e..3fef74c 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "progress": "^1.1.8", "read": "^1.0.7", "request": "^2.69.0", + "rimraf": "^2.5.2", "yauzl": "^2.4.1", "yazl": "^2.3.0" },