Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
psealock committed Feb 28, 2021
1 parent 69407d4 commit b49e316
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
19 changes: 7 additions & 12 deletions bin/hook-reference/document.js → bin/hook-reference/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const prepareHooks = async ( fileName ) => {
return await addSourceFiles( rawHooks, fileName );
};

const makeDocObject = async ( fileName ) => {
const makeDocObjects = async ( fileName ) => {
const hooks = await prepareHooks( fileName );
return hooks.map( ( { description, tags, sourceFile } ) => {
const example = tags.find( ( tag ) => tag.tag === 'example' );
Expand All @@ -48,18 +48,13 @@ const makeDocObject = async ( fileName ) => {
} );
};

const makeJSONFile = async ( docObjects ) => {
// Make JSON File here
console.log( docObjects );
};

const makeDocument = async ( fileNames ) => {
const docObjects = await Promise.all(
fileNames.map( async ( f ) => {
return await makeDocObject( f );
const createData = async ( fileNames ) => {
const data = await Promise.all(
fileNames.map( async ( fileName ) => {
return await makeDocObjects( fileName );
} )
);
makeJSONFile( docObjects.flat() );
return data.flat();
};

module.exports = makeDocument;
module.exports = createData;
10 changes: 8 additions & 2 deletions bin/hook-reference/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const makeDocument = require( './document' );
const createData = require( './data' );
const { promisify } = require( 'util' );
const { resolve } = require( 'path' );
const fs = require( 'fs' );
Expand All @@ -16,6 +16,12 @@ async function getFiles( dir ) {
return files.reduce( ( a, f ) => a.concat( f ), [] );
}

const writeJSONFile = ( data ) => {
// Make JSON File here
console.log( data );
};

getFiles( 'client' )
.then( ( fileNames ) => makeDocument( fileNames ) )
.then( ( fileNames ) => createData( fileNames ) )
.then( ( data ) => writeJSONFile( data ) )
.catch( ( e ) => console.error( e ) );

0 comments on commit b49e316

Please sign in to comment.