diff --git a/helpers/local_sdk.js b/helpers/local_sdk.js index 593655c..74b29c1 100644 --- a/helpers/local_sdk.js +++ b/helpers/local_sdk.js @@ -1,46 +1,7 @@ 'use strict'; const path = require('path'); -const fse = require('fs-extra'); -const child_process = require('child_process'); -const localSdk = require(path.join(process.env.BB_SDK_SRC_DIR, 'bespoke-gulp-tasks', 'helpers', 'local_sdk.js')); +const localSDK = require(path.join(process.env.BB_SDK_SRC_DIR, 'bespoke-gulp-tasks', 'helpers', 'local_sdk.js')); const projectRootPath = path.join(__dirname, '..'); -// check / empty tmp -console.log('Preparing tmp dir'); -if (fse.existsSync('tmp')) { - fse.emptyDirSync('tmp'); -} else { - fse.ensureDirSync('tmp'); -} - -console.log('Preparing node_modules'); -if (fse.existsSync('node_modules')) { - fse.removeSync('node_modules/bookingbug-angular'); - fse.moveSync('node_modules', 'tmp/node_modules'); -} - -console.log('Local sdk prepare'); -localSdk.prepare(projectRootPath); - -console.log('Change dir to tmp'); -process.chdir('tmp'); - -console.log('Exec npm install'); -child_process.exec('npm install --global-style --no-package-lock', (error, stdout, stderr) => { - if (error) { - console.error(`exec error: ${error}`); - process.exit(1); - } - console.log(`stdout: ${stdout}`); - console.log(`stderr: ${stderr}`); - - console.log('Change dir ..'); - process.chdir('..'); - - console.log('Put node_modules back'); - fse.moveSync('tmp/node_modules', 'node_modules'); - - console.log('Local sdk symlink'); - localSdk.symlink(projectRootPath); -}); \ No newline at end of file +localSDK.link(projectRootPath); diff --git a/helpers/local_sdk.sh b/helpers/local_sdk.sh deleted file mode 100644 index f4f6566..0000000 --- a/helpers/local_sdk.sh +++ /dev/null @@ -1,20 +0,0 @@ -if [ -d 'tmp' ]; then - rm -rf ./tmp -fi - -mkdir 'tmp' - -if [ -d 'node_modules' ]; then - rm -rf ./node_modules/bookingbug-angular - mv ./node_modules ./tmp/node_modules -fi - -node ./helpers/local_sdk_prepare.js # create tmp/package.json that refers relatively to local sdk - -cd ./tmp -npm install --global-style --no-package-lock -cd .. - -mv ./tmp/node_modules ./node_modules - -node ./helpers/local_sdk_symlink \ No newline at end of file diff --git a/helpers/local_sdk_prepare.js b/helpers/local_sdk_prepare.js deleted file mode 100644 index a4eaebe..0000000 --- a/helpers/local_sdk_prepare.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -const path = require('path'); -const localSdk = require(path.join(process.env.BB_SDK_SRC_DIR, 'bespoke-gulp-tasks', 'helpers', 'local_sdk.js')); -const projectRootPath = path.join(__dirname, '..'); - -localSdk.prepare(projectRootPath); diff --git a/helpers/local_sdk_symlink.js b/helpers/local_sdk_symlink.js deleted file mode 100644 index ccbe603..0000000 --- a/helpers/local_sdk_symlink.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -const path = require('path'); -const localSdk = require(path.join(process.env.BB_SDK_SRC_DIR, 'bespoke-gulp-tasks', 'helpers', 'local_sdk.js')); -const projectRootPath = path.join(__dirname, '..'); - -localSdk.symlink(projectRootPath); diff --git a/package.json b/package.json index dbd1ead..e29296c 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "scripts": { "i": "rm -rf ./node_modules/bookingbug-angular package-lock.json && npm install --global-style --no-package-lock", - "il": "sh ./helpers/local_sdk.sh", + "il": "node ./helpers/local_sdk.js", "p": "gulp --root public", "p-dev": "gulp --root public --env development", "p-staging": "gulp --root public --env staging",