@@ -2,16 +2,19 @@ import path from 'path';
22import * as fspp from '../fs-promise-proxy' ;
33
44const getFullData = ( data , cfg ) => Object . assign ( { } , cfg . data , data ) ;
5- export const makeDestPath = ( data , cfg , plop ) =>
6- path . resolve (
7- plop . getDestBasePath ( ) ,
8- plop . renderString ( cfg . path || '' , getFullData ( data , cfg ) )
9- ) ;
5+
6+ export const normalizePath = path => {
7+ return ! path . sep || path . sep === '\\' ? path . replace ( / \\ / g, '/' ) : path ;
8+ } ;
9+
10+ export const makeDestPath = ( data , cfg , plop ) => {
11+ return path . resolve ( plop . getDestBasePath ( ) , plop . renderString ( normalizePath ( cfg . path ) || '' , getFullData ( data , cfg ) ) ) ;
12+ } ;
1013
1114export function getRenderedTemplatePath ( data , cfg , plop ) {
1215 if ( cfg . templateFile ) {
1316 const absTemplatePath = path . resolve ( plop . getPlopfilePath ( ) , cfg . templateFile ) ;
14- return plop . renderString ( absTemplatePath , getFullData ( data , cfg ) ) ;
17+ return plop . renderString ( normalizePath ( absTemplatePath ) , getFullData ( data , cfg ) ) ;
1518 }
1619 return null ;
1720}
@@ -37,8 +40,7 @@ export function* getRenderedTemplate(data, cfg, plop) {
3740 return plop . renderString ( template , getFullData ( data , cfg ) ) ;
3841}
3942
40- export const getRelativeToBasePath = ( filePath , plop ) =>
41- filePath . replace ( path . resolve ( plop . getDestBasePath ( ) ) , '' ) ;
43+ export const getRelativeToBasePath = ( filePath , plop ) => filePath . replace ( path . resolve ( plop . getDestBasePath ( ) ) , '' ) ;
4244
4345export const throwStringifiedError = err => {
4446 if ( typeof err === 'string' ) {
0 commit comments