@@ -28,8 +28,7 @@ const pAll = async (obj) => {
2828 } , { } )
2929}
3030
31- const run = async ( params ) => {
32- const { content, template, nav, man, html, md } = params
31+ const run = async ( { content, template, nav, man, html, md } ) => {
3332 await rmAll ( man , html , md )
3433 const [ contentPaths , navFile , options ] = await Promise . all ( [
3534 readDocs ( content ) ,
@@ -92,37 +91,41 @@ const run = async (params) => {
9291 ...( fullName === 'using-npm/config'
9392 ? [ transform . shorthands , transform . config ]
9493 : [ ] ) ,
95- ] ) ;
96-
97- [ 'man' , 'html' , 'md' ] . forEach ( ( type ) => {
98- const isMan = type === 'man'
99- const DUPLICATED_FOLDER_PATH = 'configuring-npm/'
100- const FOLDER_PREFIX = isMan ? '' : DUPLICATED_FOLDER_PATH
101- const trs = [ transform [ type ] ]
102-
103- let paths = [
104- isMan ? name : fullName ,
105- fullName === `${ DUPLICATED_FOLDER_PATH } package-json` && `${ FOLDER_PREFIX } npm-json` ,
106- fullName === `${ DUPLICATED_FOLDER_PATH } folders` && `${ FOLDER_PREFIX } npm-global` ,
107- ] . filter ( Boolean )
108-
109- if ( isMan && data . section ) {
110- paths = paths . map ( p => applyTransforms ( p , [ transform . manPath ] ) )
111- trs . unshift ( transform . helpLinks )
112- const manSrc = applyTransforms ( transformedSrc , trs )
113- acc . man . push ( ...paths . map ( ( manPath ) => ( {
114- path : manPath ,
115- fullPath : join ( man , manPath ) ,
116- src : manSrc ,
117- } ) ) )
118- } else {
119- acc [ type ] . push ( ...paths . map ( ( path ) => ( {
120- path : `${ path } .${ type } ` ,
121- fullPath : join ( params [ type ] , `${ path } .${ type } ` ) ,
122- src : applyTransforms ( transformedSrc , trs ) ,
123- } ) ) )
124- }
94+ ] )
95+
96+ const aliases = [
97+ fullName === 'configuring-npm/package-json' && 'configuring-npm/npm-json' ,
98+ fullName === 'configuring-npm/folders' && 'configuring-npm/npm-global' ,
99+ ] . filter ( Boolean )
100+
101+ if ( data . section ) {
102+ // Man page aliases are only the basename since the man pages have no hierarchy
103+ acc . man . push ( ...[ name , ...aliases . map ( a => basename ( a ) ) ] . map ( ( manPath ) => ( {
104+ path : applyTransforms ( manPath , [ transform . manPath ] ) ,
105+ fullPath : join ( man , manPath ) ,
106+ src : applyTransforms ( transformedSrc , [
107+ transform . helpLinks ,
108+ transform . man ,
109+ ] ) ,
110+ } ) ) )
111+ }
112+
113+ // html docs are used for npm help on Windows
114+ acc . html . push ( ...[ fullName , ...aliases ] . map ( ( htmlPath ) => ( {
115+ path : `${ htmlPath } .html` ,
116+ fullPath : join ( html , `${ htmlPath } .html` ) ,
117+ src : applyTransforms ( transformedSrc , [ transform . html ] ) ,
118+ } ) ) )
119+
120+ // Markdown pages don't get aliases here. These are used to build the website so any redirects
121+ // for these pages are applied in npm/documentation. Not ideal but there are also many more
122+ // redirects that we would never apply to man or html docs pages
123+ acc . md . push ( {
124+ path : childPath ,
125+ fullPath : join ( md , childPath ) ,
126+ src : applyTransforms ( transformedSrc , [ transform . md ] ) ,
125127 } )
128+
126129 return acc
127130 } , { man : [ ] , html : [ ] , md : [ ] } )
128131
0 commit comments