hapipal / hpal

hapi pal CLI
https://hapipal.com
MIT License
51 stars 7 forks source link

Support relative paths in Print.requires #21

Closed timcosta closed 5 years ago

timcosta commented 5 years ago

Allows for relative path importing in .hc.js files.

Use case is for people (like me) with custom database models or such that want to do something like

module.exports = {
    add: [{
        place: 'models',
        list: true,
        signature: ['name', 'schema'],
        method: (server, options, name, schema) => {

            const { Database } = server.app;

            server.app.models = server.app.models || {};
            server.app.models[name] = Database[name];
        },
        example: {
            $requires: [
                'atlas',
                './database'
            ],
            $value: {
                name: 'ModelName',
                schema: { $literal: 'Database.addModel(\'ModelName\', new Atlas.Model())'}
            }
        }
    }]
};
coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling c12cdf65ed1392bfaf9e63110b8c63e96345b331 on timcosta:support_relative_path_requires into 237cf20cc4c7ff50daf91a6f96e4c65e44f3af73 on hapipal:master.