Browse files

Adding limited Windows support.

  • Loading branch information...
1 parent db325ff commit 8df4768d54fa9366dcaad26ef4725f9a6b9403c7 Josh Mervine committed Jul 16, 2013
Showing with 63 additions and 4 deletions.
  1. +20 −0 NOTES.mdown
  2. +17 −0 README.md
  3. +9 −0 install.js
  4. +5 −1 package.json
  5. +12 −3 { → scripts}/install.sh
View
20 NOTES.mdown
@@ -0,0 +1,20 @@
+YSlow.js is installed in the code base by default, however,
+on installation an install script is run to ensure that the
+pathing is setup correctly. This install script does not support
+Windows.
+
+Pathing to `yslow.js` is in the Mac / Linux format. As a
+workaround you should be able to simply add the following
+when initializing `YSlow`.
+
+YSlow.js isntallation isn't supported on Windows. See
+http://yslow.org/phantomjs for Windows installation
+instructions.
+
+ var YSlow = require('yslowjs');
+ YSlow.prototype.script = '/path/to/yslow.js';
+
+If this doesn't work, the failover is to isntall `yslow.js`
+(http://yslow.org/phantomjs) and specify the path as shown
+above.
+
View
17 README.md
@@ -20,6 +20,23 @@ YSlow.js on [Node.js](http://mervine.net/nodejs) is a simple [Node.js](http://me
:::shell
$ npm install yslowjs
+#### Additional Installation Notes
+
+You can specify different versions of [YSlow.js](http://mervine.net/yslowjs) using `npm config`:
+
+ $ npm config set yslowjs_version
+
+> You will have to reinstall `yslowjs` if you change this option after initially installing it.
+
+I've added limited Windows support, in that things should work by default, YSlow.js should be there and ready to use. If it doesn't, you'll have to install [`yslow.js`](http://yslow.org/phantomjs) yourself and specify the path like so:
+
+ :::js
+ var YSlow = require('yslowjs');
+ YSlow.prototype.script = 'c:\path\to\yslow.js';
+
+> It's important to note that I haven't tested this on Windows (and don't really have an easy way to), so feedback and/or pull requests are welcome.
+
+
## Configuration Options
:::js
View
9 install.js
@@ -0,0 +1,9 @@
+if (process.platform === 'win32') {
+ require('fs').readFile('./NOTES.mdown', 'utf8', function(err, data) {
+ console.log(data);
+ process.exit(0);
+ });
+} else {
+ require('child_process')
+ .spawn('./scripts/install.sh', [], { stdio: 'inherit', env: process.env });
+}
View
6 package.json
@@ -4,7 +4,11 @@
"description": "Wrapper for phantomjs yslow.js",
"main": "./lib/yslow.js",
"scripts": {
- "test": "make test"
+ "test": "make test",
+ "install": "node install.js"
+ },
+ "config": {
+ "yslowjs_version": "3.1.5"
},
"repository": {
"type": "git",
View
15 install.sh → scripts/install.sh
@@ -1,8 +1,14 @@
#!/usr/bin/env bash
-libdir="$(echo $(cd $(dirname $0); pwd)/lib)"
-#http://yslow.org/yslow-phantomjs-3.1.5.zip
+libdir="$(echo $(cd $(dirname $0)/..; pwd)/lib)"
srcpath="http://yslow.org"
version="3.1.5"
+
+if test "$npm_config_yslowjs_version"; then
+ version="$npm_config_yslowjs_version"
+else
+ version="$npm_package_config_yslowjs_version"
+fi
+
yspkg="yslow-phantomjs-$version.zip"
decomp="unzip -q -o"
@@ -61,17 +67,20 @@ else
fi
# decompress package
+echo " "
echo "Decompressing $yspkg"
$decomp $yspkg
if [ $? -ne 0 ]; then
echo "Error occured decompressing $yspkg"
exit 1
fi
-mv yslow.js $libdir/yslow_phantom.js
+
+cp $(pwd)/yslow.js $libdir/yslow_phantom.js
if [ $? -ne 0 ]; then
echo "Error moving yslow.js in to place."
exit 1
fi
+echo " "
write_yspath_js "$libdir/yslow_phantom.js"
yay_finished

0 comments on commit 8df4768

Please sign in to comment.