Skip to content

Commit

Permalink
fix: remove 'removeSafe' function
Browse files Browse the repository at this point in the history
  • Loading branch information
gerard2perez committed Sep 20, 2017
1 parent ff8b576 commit 40b195f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 16 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ globals:
readDir: true
requireNoCache: false
TemplatePath: true
requireSafe: .3true
Events: true
LibPath: true
makeObjIterable: true
Expand Down
13 changes: 3 additions & 10 deletions src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ global.makeObjIterable = function makeObjIterable (obj) {
};
global.requireUnCached = function (lib) {
delete require.cache[require.resolve(lib)];
return requireSafe(lib);
return require(lib);
};
global.cleanString = (text) => {
return text.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
Expand All @@ -54,20 +54,13 @@ global.Events = async (phase, event) => {
await require(path.resolve(file)).default(ProyPath());
}
};
global.requireSafe = function requireSafe (lib, defaults) {
try {
return require(lib);
} catch (e) {
return defaults;
}
};
global.requireNoCache = function requireNoCache (lib, defaults) {
global.requireNoCache = function requireNoCache (lib) {
let library = rawpath.normalize(rawpath.resolve(lib));
if (library.indexOf('.json') === -1) {
library = library.replace('.js', '') + '.js';
}
delete require.cache[library];
return requireSafe(library, defaults);
return require(library);
};
global.CLIPath = function CLIPath (...args) {
args.splice(0, 0, __dirname);
Expand Down
6 changes: 4 additions & 2 deletions src/support/CheckBundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ async function DetectChanges (changed) {
let removed = current.filter(o => { return incoming.indexOf(o) === -1; });
for (const add of added) {
mustrebuild = true;
allBundles[bundle].add(add);
// allBundles[bundle].add(add);
hashes[resolve(add)] = await hasfile(add);
}
for (const remove of removed) {
mustrebuild = true;
allBundles[bundle].remove(remove);
// allBundles[bundle].remove(remove);
delete hashes[resolve(remove)];
}
allBundles[bundle].clear();
incoming.forEach(allBundles[bundle].add);
} else {
mustrebuild = true;
allBundles[bundle] = new BundleItem(bundle, newconf[bundle], true);
Expand Down
2 changes: 1 addition & 1 deletion src/support/CopyStatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function fail () {
}

export default async function copystatic () {
const config = requireNoCache(ProyPath('config', 'static'), {default: {}}).default.copy;
const config = requireNoCache(ProyPath('config', 'static')).default.copy;
let promises = [];
for (const bundle of config) {
let compiled = false;
Expand Down
2 changes: 1 addition & 1 deletion src/support/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class ServerConfiguaration {
});
Object.defineProperty(this, '_emberapps', {
enumerable: false,
value: Object.assign({}, requireSafe(ProyPath('config', 'ember'), {}).default)
value: Object.assign({}, require(ProyPath('config', 'ember')).default)
});
makeObjIterable(this._emberapps);
Object.defineProperty(this, 'localserver', {
Expand Down
2 changes: 1 addition & 1 deletion src/support/inflector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as inflector from 'inflection';
const inflections = Object.assign({}, {
plural: [],
singular: []
}, requireSafe(ProyPath('config', 'inflections'), {}));
}, require(ProyPath('config', 'inflections')));

for (const inflect in inflections.singular) {
inflector.singularize(...inflect);
Expand Down

0 comments on commit 40b195f

Please sign in to comment.