Made copy-static-res independent of the leaflet version.
@@ -10,16 +10,7 @@ var sassImportOnce = require('node-sass-import-once');
var gulp_jspm = require('gulp-jspm');
var sourcemaps = require('gulp-sourcemaps');
-require('./jspm_packages/system.js');
-require('./jspm_config.js');
-console.log('System: ', System.map['leaflet']);
-// try to get the path directly from systemjs?
-// or use https://www.npmjs.com/package/jspm-resolve ? (gives the path)
-// there's also a `paths: {<glob> : <base-path> }` that gives the base-path
-// system.locate ?
-// System.normalize ?
-// System.module ?
gulp.task('default', ['build']);
gulp.task('build', ['sass', 'iconsprite', 'bundlejs', 'copy-static-res']);
@@ -71,7 +62,7 @@ gulp.task('sass', function(done) {
*/
gulp.task('copy-static-res', function(done) {
return gulp.src([
- './jspm_packages/npm/leaflet@0.7.7/dist/images/**/*'
+ getRelModuleFolderPath('leaflet') + 'dist/images/**/*',
])
.pipe(gulp.dest('./generated/images/'))
});
@@ -127,6 +118,31 @@ gulp.task('clean', function () {
rimraf('./generated', function(){});
});
+
+
+require('./jspm_packages/system.js');
+require('./jspm_config.js');
+
+function getRelModuleFolderPath(moduleName) {
+ var absolutePath = getAbsModuleFolderPath(moduleName);
+
+ // example:
+ // * abs: https://localhost:8443/owner/jspm_packages/npm/leaflet@0.7.7.js
+ // * baseURL: https://localhost:8443/
+ // ==> ./jspm_packages/npm/leaflet@0.7.7/dist/images/**/*
+
+ return './' + absolutePath.substr(System.baseURL.length)
+}
+
+function getAbsModuleFolderPath(moduleName) {
+
+ // e.g. "https://localhost:8443/owner/jspm_packages/npm/leaflet@0.7.7.js"
+ var modulePath = System.normalizeSync(moduleName);
+
+ var folderPath = modulePath.substr(0, modulePath.length - 3) + '/'; // remove `.js`
+ return folderPath;
+}
+
//npm install --save-dev "gulp-dgeni" "gulp-esdoc" "gulp-jsdoc" "dgeni" "dgeni-packages"
//var dgeni = require('gulp-dgeni');A
//var ngdoc = require('dgeni-packages/ngdoc');
