From 56a3c35b464fe05974f8bc96441db1c57a7efba6 Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Thu, 26 Jan 2012 10:54:16 -0800 Subject: [PATCH 1/3] #2: Make samples work with relative path OR with npm module --- examples/blobuploader/package.json | 1 + examples/blobuploader/server.js | 8 +++++++- examples/blog/blog.js | 8 +++++++- examples/blog/package.json | 1 + examples/samples/blobuploaddownloadsample.js | 9 +++++++-- examples/samples/continuationsample.js | 8 +++++++- examples/samples/leaseblobsample.js | 8 +++++++- examples/samples/retrypolicysample.js | 8 +++++++- examples/samples/sassample.js | 8 +++++++- examples/samples/snapshotsample.js | 8 +++++++- examples/tasklist/home.js | 9 ++++++++- examples/tasklist/package.json | 1 + examples/tasklist/server.js | 8 +++++++- 13 files changed, 74 insertions(+), 11 deletions(-) diff --git a/examples/blobuploader/package.json b/examples/blobuploader/package.json index 71c2032565..950ea89165 100644 --- a/examples/blobuploader/package.json +++ b/examples/blobuploader/package.json @@ -6,5 +6,6 @@ "express": ">= 2.4.7" , "ejs": ">= 0.4.3" , "formidable": ">= 1.0.6" + , "azure": ">= 0.5.1" } } \ No newline at end of file diff --git a/examples/blobuploader/server.js b/examples/blobuploader/server.js index 054fac6932..df0cc497fd 100644 --- a/examples/blobuploader/server.js +++ b/examples/blobuploader/server.js @@ -1,6 +1,12 @@ +var path = require('path'); +if (path.existsSync('./../../lib/azure.js')) { + azure = require('./../../lib/azure'); +} else { + azure = require('azure'); +} + var express = require('express'); var formidable = require('formidable'); -var azure = require('./../../lib/azure'); var helpers = require('./helpers.js'); var app = module.exports = express.createServer(); diff --git a/examples/blog/blog.js b/examples/blog/blog.js index 34b12039d7..b1b172620a 100644 --- a/examples/blog/blog.js +++ b/examples/blog/blog.js @@ -1,4 +1,10 @@ -var azure = require('./../../lib/azure'); +var path = require('path'); +if (path.existsSync('./../../lib/azure.js')) { + azure = require('./../../lib/azure'); +} else { + azure = require('azure'); +} + var ServiceClient = azure.ServiceClient; var TableQuery = azure.TableQuery; var uuid = require('node-uuid'); diff --git a/examples/blog/package.json b/examples/blog/package.json index 7e5a706fb5..6927967d79 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -7,5 +7,6 @@ , "stylus": ">= 0.0.1" , "ejs": ">= 0.4.3" , "node-uuid": ">= 1.2.0" + , "azure": ">= 0.5.1" } } diff --git a/examples/samples/blobuploaddownloadsample.js b/examples/samples/blobuploaddownloadsample.js index d4a6aa2b89..e3c30a594b 100644 --- a/examples/samples/blobuploaddownloadsample.js +++ b/examples/samples/blobuploaddownloadsample.js @@ -6,13 +6,18 @@ * 3. Demonstrate making requests using AccessConditions. */ -var azure = require('../../lib/azure'); +var path = require('path'); +if (path.existsSync('./../../lib/azure.js')) { + azure = require('./../../lib/azure'); +} else { + azure = require('azure'); +} + var BlobConstants = azure.Constants.BlobConstants; var ServiceClient = azure.ServiceClient; var CloudBlobClient = azure.CloudBlobClient; var util = require('util'); -var path = require('path'); var fs = require('fs'); var container = 'updownsample'; diff --git a/examples/samples/continuationsample.js b/examples/samples/continuationsample.js index 184d4370e6..6f9fd68441 100644 --- a/examples/samples/continuationsample.js +++ b/examples/samples/continuationsample.js @@ -16,7 +16,13 @@ * */ -var azure = require('../../lib/azure'); +var path = require('path'); +if (path.existsSync('./../../lib/azure.js')) { + azure = require('./../../lib/azure'); +} else { + azure = require('azure'); +} + var BlobConstants = azure.Constants.BlobConstants; var ServiceClient = azure.ServiceClient; var CloudBlobClient = azure.CloudBlobClient; diff --git a/examples/samples/leaseblobsample.js b/examples/samples/leaseblobsample.js index 8aa591298b..e67f967296 100644 --- a/examples/samples/leaseblobsample.js +++ b/examples/samples/leaseblobsample.js @@ -13,7 +13,13 @@ * */ -var azure = require('../../lib/azure'); +var path = require('path'); +if (path.existsSync('./../../lib/azure.js')) { + azure = require('./../../lib/azure'); +} else { + azure = require('azure'); +} + var BlobConstants = azure.Constants.BlobConstants; var ServiceClient = azure.ServiceClient; var CloudBlobClient = azure.CloudBlobClient; diff --git a/examples/samples/retrypolicysample.js b/examples/samples/retrypolicysample.js index f07eefb6eb..51add3c4ab 100644 --- a/examples/samples/retrypolicysample.js +++ b/examples/samples/retrypolicysample.js @@ -8,7 +8,13 @@ * sent if users immediately recreate a container after delete it. */ -var azure = require('../../lib/azure'); +var path = require('path'); +if (path.existsSync('./../../lib/azure.js')) { + azure = require('./../../lib/azure'); +} else { + azure = require('azure'); +} + var BlobConstants = azure.Constants.BlobConstants; var ServiceClient = azure.ServiceClient; var CloudBlobClient = azure.CloudBlobClient; diff --git a/examples/samples/sassample.js b/examples/samples/sassample.js index ebc45be128..3d948e32aa 100644 --- a/examples/samples/sassample.js +++ b/examples/samples/sassample.js @@ -20,7 +20,13 @@ * c. Use both shared access signatures to read that blob (Expect a failure from the "Read" permission shared access signature since it has already expired.). */ -var azure = require('../../lib/azure'); +var path = require('path'); +if (path.existsSync('./../../lib/azure.js')) { + azure = require('./../../lib/azure'); +} else { + azure = require('azure'); +} + var BlobConstants = azure.Constants.BlobConstants; var ServiceClient = azure.ServiceClient; var CloudBlobClient = azure.CloudBlobClient; diff --git a/examples/samples/snapshotsample.js b/examples/samples/snapshotsample.js index f55c817752..3f4dcc7b97 100644 --- a/examples/samples/snapshotsample.js +++ b/examples/samples/snapshotsample.js @@ -18,7 +18,13 @@ * 8. List all snapshots for this blob. */ -var azure = require('../../lib/azure'); +var path = require('path'); +if (path.existsSync('./../../lib/azure.js')) { + azure = require('./../../lib/azure'); +} else { + azure = require('azure'); +} + var BlobConstants = azure.Constants.BlobConstants; var ServiceClient = azure.ServiceClient; var CloudBlobClient = azure.CloudBlobClient; diff --git a/examples/tasklist/home.js b/examples/tasklist/home.js index ec88bf1aac..d27630de41 100644 --- a/examples/tasklist/home.js +++ b/examples/tasklist/home.js @@ -1,4 +1,11 @@ -var TableQuery = require('./../../lib/azure').TableQuery; +var path = require('path'); +if (path.existsSync('./../../lib/azure.js')) { + azure = require('./../../lib/azure'); +} else { + azure = require('azure'); +} + +var TableQuery = azure.TableQuery; module.exports = Home; var uuid = require('node-uuid'); diff --git a/examples/tasklist/package.json b/examples/tasklist/package.json index 355534d179..74dfb183e8 100644 --- a/examples/tasklist/package.json +++ b/examples/tasklist/package.json @@ -7,5 +7,6 @@ , "ejs": ">= 0.4.3" , "jade": ">= 0.18.0" , "node-uuid": "> = 1.2.0" + , "azure": ">= 0.5.1" } } \ No newline at end of file diff --git a/examples/tasklist/server.js b/examples/tasklist/server.js index 004d66f276..82ea347795 100644 --- a/examples/tasklist/server.js +++ b/examples/tasklist/server.js @@ -1,8 +1,14 @@ // Module dependencies. +var path = require('path'); +if (path.existsSync('./../../lib/azure.js')) { + azure = require('./../../lib/azure'); +} else { + azure = require('azure'); +} + var express = require('express'); var uuid = require('node-uuid'); var Home = require('./home'); -var azure = require('./../../lib/azure'); var ServiceClient = azure.ServiceClient; var app = module.exports = express.createServer(); From 3ba47a1db0eedf443efa3c23f1a7d21b72fc768a Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Thu, 26 Jan 2012 10:54:29 -0800 Subject: [PATCH 2/3] #33: Improving how environment value for emulated is handled. --- lib/services/serviceclient.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/services/serviceclient.js b/lib/services/serviceclient.js index 4c8a0dade4..19d0c0752f 100644 --- a/lib/services/serviceclient.js +++ b/lib/services/serviceclient.js @@ -677,7 +677,8 @@ ServiceClient.isEmulated = function (host) { return true; } - return process.env[ServiceClient.EnvironmentVariables.EMULATED] ? true : false; + return (!azureutil.isNull(process.env[ServiceClient.EnvironmentVariables.EMULATED]) && + process.env[ServiceClient.EnvironmentVariables.EMULATED] !== 'false'); }; // Other functions From 268422e533a5ae14ea62ad2395aff08a5238ffee Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Thu, 26 Jan 2012 10:54:59 -0800 Subject: [PATCH 3/3] Removing jshint from devDependencies as it is now a global module. --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 29f4fe6533..9522804e97 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,7 @@ "mime": ">= 1.2.4" }, "devDependencies": { - "nodeunit": ">= 0.6.4", - "jshint": ">= 0.5.2" + "nodeunit": ">= 0.6.4" }, "homepage": "http://github.com/WindowsAzure/azure-sdk-for-node", "repository": {