Getting the root path of the app in sails controllers #82
Closed
MaheshkumarSundaram
started this conversation in
General
Replies: 1 comment 1 reply
-
Here's a quick n dirty helper (put in const { resolve } = require('path');
module.exports = {
sync: true, // this is a synchronous helper
friendlyName: 'Get Project Root Directory',
description: 'Returns the project root directory',
inputs: {},
exits: {},
fn: function(inputs, exits) {
// __dirname here will be something like `/home/user/my-project/api/helpers`
// path.resolve() here will return something like `/home/user/my-project`
return exits.success(resolve(__dirname, '../../'));
}
}; |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi @neonexus,
Say my root folder is: "F:/myProjects/myWebApp/".
I would like to get this root path in any of Sails controllers.
I know Node.js has a lot of options. But it seems most of them may or may not work based on how I run the app and other things.
Could you please let me know if there is any reliable way to get the root path?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions