-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (35 loc) · 1003 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*jshint node: true */
'use strict';
var fs = require('fs'),
convert = require('./convert'),
config = require('./config');
module.exports = function notobo(options, callback) {
// For that authentic async callback feel.
process.nextTick(function() {
try {
var loaderConfigFile = options.loaderConfigFile,
baseUrl = options.baseUrl;
if (!baseUrl) {
baseUrl = 'node_modules';
}
if (!fs.existsSync(baseUrl)) {
throw new Error(baseUrl + ' does not exist');
}
if (!loaderConfigFile) {
throw new Error('No path to file that contains the AMD config');
}
if (!fs.existsSync(loaderConfigFile)) {
throw new Error(loaderConfigFile + ' does not exist');
}
convert(baseUrl, options, function(err, walked) {
if (err) {
callback(err);
} else {
config(walked, loaderConfigFile, callback);
}
});
} catch (e) {
callback(e);
}
});
};