@@ -8,8 +8,17 @@ var eol = require('os').EOL,
88 path = require ( 'path' ) ,
99 defaultBinaryPath = path . join ( __dirname , '..' , 'vendor' ) ;
1010
11- function getHumanPlatform ( arg ) {
12- switch ( arg || process . platform ) {
11+ /**
12+ * Get the human readable name of the Platform that is running
13+ *
14+ * @param {string } platform - An OS platform to match, or null to fallback to
15+ * the current process platform
16+ * @return {Object } The name of the platform if matched, false otherwise
17+ *
18+ * @api public
19+ */
20+ function getHumanPlatform ( platform ) {
21+ switch ( platform || process . platform ) {
1322 case 'darwin' : return 'OS X' ;
1423 case 'freebsd' : return 'FreeBSD' ;
1524 case 'linux' : return 'Linux' ;
@@ -18,17 +27,36 @@ function getHumanPlatform(arg) {
1827 }
1928}
2029
21- function getHumanArchitecture ( arg ) {
22- switch ( arg || process . arch ) {
30+ /**
31+ * Provides a more readable version of the architecture
32+ *
33+ * @param {string } arch - An instruction architecture name to match, or null to
34+ * lookup the current process architecture
35+ * @return {Object } The value of the process architecture, or false if unknown
36+ *
37+ * @api public
38+ */
39+ function getHumanArchitecture ( arch ) {
40+ switch ( arch || process . arch ) {
2341 case 'ia32' : return '32-bit' ;
2442 case 'x86' : return '32-bit' ;
2543 case 'x64' : return '64-bit' ;
2644 default : return false ;
2745 }
2846}
2947
30- function getHumanNodeVersion ( arg ) {
31- switch ( parseInt ( arg || process . versions . modules , 10 ) ) {
48+ /**
49+ * Get the friendly name of the Node environment being run
50+ *
51+ * @param {Object } abi - A Node Application Binary Interface value, or null to
52+ * fallback to the current Node ABI
53+ * @return {Object } Returns a string name of the Node environment or false if
54+ * unmatched
55+ *
56+ * @api public
57+ */
58+ function getHumanNodeVersion ( abi ) {
59+ switch ( parseInt ( abi || process . versions . modules , 10 ) ) {
3260 case 11 : return 'Node 0.10.x' ;
3361 case 14 : return 'Node 0.12.x' ;
3462 case 42 : return 'io.js 1.x' ;
@@ -42,6 +70,16 @@ function getHumanNodeVersion(arg) {
4270 }
4371}
4472
73+ /**
74+ * Get a human readable description of where node-sass is running to support
75+ * user error reporting when something goes wrong
76+ *
77+ * @param {string } env - The name of the native bindings that is to be parsed
78+ * @return {string } A description of what os, architecture, and Node version
79+ * that is being run
80+ *
81+ * @api public
82+ */
4583function getHumanEnvironment ( env ) {
4684 var binding = env . replace ( / _ b i n d i n g \. n o d e $ / , '' ) ,
4785 parts = binding . split ( '-' ) ,
@@ -70,15 +108,33 @@ function getHumanEnvironment(env) {
70108 ] . join ( ' ' ) ;
71109}
72110
111+ /**
112+ * Get the value of the binaries under the default path
113+ *
114+ * @return {Array } The currently installed node-sass bindings
115+ *
116+ * @api public
117+ */
73118function getInstalledBinaries ( ) {
74119 return fs . readdirSync ( defaultBinaryPath ) ;
75120}
76121
77- function isSupportedEnvironment ( platform , arch , runtime ) {
122+ /**
123+ * Check that an environment matches the whitelisted values or the current
124+ * environment if no parameters are passed
125+ *
126+ * @param {string } platform - The name of the OS platform(darwin, win32, etc...)
127+ * @param {string } arch - The instruction set architecture of the Node environment
128+ * @param {string } abi - The Node Application Binary Interface
129+ * @return {Boolean } True, if node-sass supports the current platform, false otherwise
130+ *
131+ * @api public
132+ */
133+ function isSupportedEnvironment ( platform , arch , abi ) {
78134 return (
79135 false !== getHumanPlatform ( platform ) &&
80136 false !== getHumanArchitecture ( arch ) &&
81- false !== getHumanNodeVersion ( runtime )
137+ false !== getHumanNodeVersion ( abi )
82138 ) ;
83139}
84140
0 commit comments