Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit a866e9b

Browse files
committed
Require PathUtils instead of using the global one
1 parent 57e18b9 commit a866e9b

10 files changed

Lines changed: 31 additions & 20 deletions

File tree

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
"require": false,
6565
"define": false,
6666
"$": false,
67-
"PathUtils": false,
6867
"Mustache": false
6968
}
7069
}

src/LiveDevelopment/Agents/CSSAgent.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, forin: true, maxerr: 50, regexp: true */
26-
/*global define, $, PathUtils */
26+
/*global define, $ */
2727

2828
/**
2929
* CSSAgent keeps track of loaded style sheets and allows reloading them
@@ -35,12 +35,11 @@
3535
define(function CSSAgent(require, exports, module) {
3636
"use strict";
3737

38-
require("thirdparty/path-utils/path-utils.min");
39-
4038
var _ = require("thirdparty/lodash");
4139

4240
var Inspector = require("LiveDevelopment/Inspector/Inspector"),
43-
EventDispatcher = require("utils/EventDispatcher");
41+
EventDispatcher = require("utils/EventDispatcher"),
42+
PathUtils = require("thirdparty/path-utils/path-utils");
4443

4544
/**
4645
* Stylesheet details

src/brackets.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ define(function (require, exports, module) {
3939
"use strict";
4040

4141
// Load dependent non-module scripts
42-
require("thirdparty/path-utils/path-utils.min");
4342
require("widgets/bootstrap-dropdown");
4443
require("widgets/bootstrap-modal");
4544
require("widgets/bootstrap-twipsy-mod");
@@ -115,6 +114,18 @@ define(function (require, exports, module) {
115114
}
116115
});
117116

117+
// DEPRECATED: In future we want to remove the global PathUtils, but for now we
118+
// expose our required PathUtils globally so as to avoid breaking extensions in the
119+
// interim.
120+
var PathUtils = require("thirdparty/path-utils/path-utils");
121+
122+
Object.defineProperty(window, "PathUtils", {
123+
get: function () {
124+
DeprecationWarning.deprecationWarning('Use brackets.getModule("thirdparty/path-utils/path-utils") instead of global PathUtils.', true);
125+
return PathUtils;
126+
}
127+
});
128+
118129
// Load modules that self-register and just need to get included in the main project
119130
require("command/DefaultMenus");
120131
require("document/ChangedDocumentTracker");

src/extensibility/Package.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
/*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, regexp: true,
2626
indent: 4, maxerr: 50 */
27-
/*global define, $, brackets, PathUtils */
27+
/*global define, $, brackets */
2828

2929
/**
3030
* Functions for working with extension packages
@@ -39,7 +39,8 @@ define(function (require, exports, module) {
3939
Strings = require("strings"),
4040
ExtensionLoader = require("utils/ExtensionLoader"),
4141
NodeConnection = require("utils/NodeConnection"),
42-
PreferencesManager = require("preferences/PreferencesManager");
42+
PreferencesManager = require("preferences/PreferencesManager"),
43+
PathUtils = require("thirdparty/path-utils/path-utils");
4344

4445
PreferencesManager.definePreference("proxy", "string", undefined, {
4546
description: Strings.DESCRIPTION_PROXY

src/extensions/default/QuickView/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
25-
/*global define, brackets, $, window, PathUtils */
25+
/*global define, brackets, $, window */
2626

2727
define(function (require, exports, module) {
2828
"use strict";
@@ -40,7 +40,8 @@ define(function (require, exports, module) {
4040
LanguageManager = brackets.getModule("language/LanguageManager"),
4141
Strings = brackets.getModule("strings"),
4242
ViewUtils = brackets.getModule("utils/ViewUtils"),
43-
TokenUtils = brackets.getModule("utils/TokenUtils");
43+
TokenUtils = brackets.getModule("utils/TokenUtils"),
44+
PathUtils = brackets.getModule("thirdparty/path-utils/path-utils");
4445

4546
var previewContainerHTML = require("text!QuickViewTemplate.html");
4647

src/extensions/default/UrlCodeHints/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ define(function (require, exports, module) {
3737
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
3838
ProjectManager = brackets.getModule("project/ProjectManager"),
3939
StringUtils = brackets.getModule("utils/StringUtils"),
40+
PathUtils = brackets.getModule("thirdparty/path-utils/path-utils"),
4041
Strings = brackets.getModule("strings"),
4142
Data = require("text!data.json"),
4243

@@ -80,7 +81,7 @@ define(function (require, exports, module) {
8081
docDir = FileUtils.getDirectoryPath(doc.file.fullPath);
8182

8283
// get relative path from query string
83-
queryUrl = window.PathUtils.parseUrl(query.queryStr);
84+
queryUrl = PathUtils.parseUrl(query.queryStr);
8485
if (queryUrl) {
8586
queryDir = queryUrl.directory;
8687
}

src/preferences/PreferencesDialogs.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
26-
/*global define, PathUtils, Mustache */
26+
/*global define, Mustache */
2727

2828
/**
2929
* PreferencesDialogs
@@ -32,13 +32,12 @@
3232
define(function (require, exports, module) {
3333
"use strict";
3434

35-
require("thirdparty/path-utils/path-utils.min");
36-
3735
var Dialogs = require("widgets/Dialogs"),
3836
ProjectManager = require("project/ProjectManager"),
3937
StringUtils = require("utils/StringUtils"),
4038
Strings = require("strings"),
41-
SettingsDialogTemplate = require("text!htmlContent/project-settings-dialog.html");
39+
SettingsDialogTemplate = require("text!htmlContent/project-settings-dialog.html"),
40+
PathUtils = require("thirdparty/path-utils/path-utils");
4241

4342
/**
4443
* Validate that text string is a valid base url which should map to a server folder

src/utils/ExtensionUtils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
26-
/*global define, $, brackets, less, PathUtils */
26+
/*global define, $, brackets, less */
2727

2828
/**
2929
* ExtensionUtils defines utility methods for implementing extensions.
@@ -33,7 +33,8 @@ define(function (require, exports, module) {
3333

3434
var Async = require("utils/Async"),
3535
FileSystem = require("filesystem/FileSystem"),
36-
FileUtils = require("file/FileUtils");
36+
FileUtils = require("file/FileUtils"),
37+
PathUtils = require("thirdparty/path-utils/path-utils");
3738

3839
/**
3940
* Appends a <style> tag to the document's head.

test/SpecRunner.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@
3737
<!-- Keep in sync with Gruntfile.js jasmine vendor dependencies -->
3838
<script src="../src/thirdparty/jquery-2.1.3.min.js"></script>
3939
<script src="../src/thirdparty/mustache/mustache.js"></script>
40-
<script src="../src/thirdparty/path-utils/path-utils.js"></script>
4140
<script src="../src/thirdparty/less-2.5.1.min.js"></script>
4241
<script src="thirdparty/bootstrap2/js/bootstrap.min.js"></script>
43-
42+
4443
<!-- All other scripts are loaded through require. -->
4544
<script src="../src/thirdparty/requirejs/require.js" data-main="SpecRunner"></script>
4645

0 commit comments

Comments
 (0)