From b4ce788ad645c5e35055303b85ee5fb42c79253a Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sat, 29 Aug 2015 19:11:38 +0200 Subject: [PATCH] gulp-my-tasks: retrieve project name form package.json In this way, gulp-my-tasks can work with any project (if it follows my patterns) --- gulp/gulp-my-tasks/tasks/server.config.js | 12 ------------ gulp/gulp-my-tasks/tasks/server.js | 8 ++++++-- gulp/gulp-my-tasks/tasks/tasks.config.js | 9 +++++---- 3 files changed, 11 insertions(+), 18 deletions(-) delete mode 100644 gulp/gulp-my-tasks/tasks/server.config.js diff --git a/gulp/gulp-my-tasks/tasks/server.config.js b/gulp/gulp-my-tasks/tasks/server.config.js deleted file mode 100644 index 7f9a2ad..0000000 --- a/gulp/gulp-my-tasks/tasks/server.config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = function() { - var main = './src/showcase/'; - var config = { - main: main, - index: main + 'index.html', - port: 9000, - script: './server.js', - directory: './server/' - }; - - return config; -}; diff --git a/gulp/gulp-my-tasks/tasks/server.js b/gulp/gulp-my-tasks/tasks/server.js index 7df30be..c293950 100644 --- a/gulp/gulp-my-tasks/tasks/server.js +++ b/gulp/gulp-my-tasks/tasks/server.js @@ -1,6 +1,10 @@ 'use strict'; var currentDir = process.cwd(); +var $ = { + path: require('path') +}; +var pkg = require($.path.join(process.cwd(), 'package.json')); var express = require('express'); var proxy = require('express-http-proxy'); var app = express(); @@ -39,11 +43,11 @@ switch (environment) { default: console.log('development mode'); - app.use(express.static(currentDir + '/src/showcase/')); + app.use(express.static(currentDir + '/src/' + pkg.name + '/')); app.use(express.static(currentDir + '/')); // Deep linking (exclude XHR requests) - app.use('/((?!api)).*', express.static(currentDir + '/src/showcase/index.html')); + app.use('/((?!api)).*', express.static(currentDir + '/src/' + pkg.name + '/index.html')); break; } diff --git a/gulp/gulp-my-tasks/tasks/tasks.config.js b/gulp/gulp-my-tasks/tasks/tasks.config.js index c578b19..317a975 100644 --- a/gulp/gulp-my-tasks/tasks/tasks.config.js +++ b/gulp/gulp-my-tasks/tasks/tasks.config.js @@ -1,14 +1,15 @@ module.exports = function() { - var main = './src/showcase/'; + var $ = { + path: require('path') + }; + var pkg = require($.path.join(process.cwd(), 'package.json')); + var main = './src/' + pkg.name + '/'; var app = main + 'app/'; var bower = { json: require(process.cwd() + '/bower.json'), directory: process.cwd() + '/bower_components/', ignorePath: '../..' }; - var $ = { - path: require('path') - }; return { main: main, -- 2.1.4