Skip to content

Commit

Permalink
make the find function in movesocket more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
annyhe committed Nov 30, 2016
1 parent 0aa6a3c commit 8e4bafb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
19 changes: 0 additions & 19 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const conf = {
default: [
'browserifyViews',
'movecss',
'movesocket',
],
},
paths: {
Expand Down Expand Up @@ -136,24 +135,6 @@ gulp.task('movecss', () =>
})
);

/*
* Moves socket io client side js to public folder
*/
gulp.task('movesocket', () =>
gulp.src('./node_modules/socket.io-client/socket.io.js')
.pipe(gulp.dest(conf.view.dest))
.on('end', () => {
process.exit();
})
);

/*
* Runs default tasks on any changes to src.
*/
gulp.task('watch', () =>
gulp.watch(conf.paths.src, ['browserifyViews', 'movecss', 'movesocket'])
);

/*
* Copy git pre-commit script to git hooks.
*/
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"type": "git",
"url": "https://github.com/Salesforce/refocus.git"
},
"watch": {
"view": "view/**/*/app.js"
},
"scripts": {
"build": "NODE_ENV=development && webpack --config ./webpack.config.js --progress --profile",
"checkdb": "node db/createOrUpdateDb.js",
Expand All @@ -23,7 +20,7 @@
"jscs": "./node_modules/jscs/bin/jscs *.js api cache clock config db jobQueue migrations realtime tests utils view worker",
"lint": "eslint view/admin",
"migratedb": "node db/migrate.js",
"postinstall": "NODE_ENV=production gulp browserifyViews && gulp movecss && gulp movesocket",
"postinstall": "NODE_ENV=production gulp browserifyViews && gulp movecss && node scripts/moveSocket.js",
"prestart": "npm run checkdb",
"start": "node --max_old_space_size=1500 --nouse-idle-notification index.js",
"start-clock": "node --max_old_space_size=1500 --nouse-idle-notification clock/index.js",
Expand Down Expand Up @@ -88,7 +85,6 @@
"multer": "^1.0.3",
"nock": "^3.6.0",
"npm": "^3.10.9",
"npm-watch": "^0.1.3",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"passport-saml": "^0.15.0",
Expand Down Expand Up @@ -116,6 +112,7 @@
"sequelize-cli": "^2.1.0",
"sequelize-hierarchy": "^0.5.0",
"serve-favicon": "^2.3.0",
"shelljs": "^0.7.5",
"sinon": "^1.17.2",
"socket.io": "^1.4.5",
"socket.io-client": "^1.4.5",
Expand Down
27 changes: 27 additions & 0 deletions scripts/moveSocket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2016, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or
* https://opensource.org/licenses/BSD-3-Clause
*/

/**
* ./scripts/moveSocket.js
*
* Call this script from the command line to move the socket.io.js from
* any folder in socket.io-client to the destination folder.
*/

require('shelljs/global');
const DEST_PATH = 'public';

const arr = find('node_modules/socket.io-client')
.filter((file) => {
return file.match(/socket.io.js$/);
});
if (arr.length !== 1) {
throw new Error('Did not find client-side socket.io script');
} else {
cp('-f', arr[0], DEST_PATH);
}

0 comments on commit 8e4bafb

Please sign in to comment.