MCPcopy Create free account
hub / github.com/socketstream/socketstream / asset

Function asset

lib/client/bundler/default.js:60–95  ·  view source on GitHub ↗
(entry, opts, cb)

Source from the content-addressed store, hash-verified

58
59 //TODO callback(err,output) for pack to flag error
60 function asset(entry, opts, cb) {
61 ss.bundler.loadFile(entry, opts, null,
62 function(output) {
63 switch(entry.bundle) {
64 case 'html':
65 return cb(ss.bundler.injectTailIfNeeded(output,opts));
66 case 'css':
67 return cb( client.includes.css? output:'');
68 case 'worker':
69 //TODO
70 if (opts.compress && entry.file.indexOf('.min') === -1) {
71 output = ss.bundler.minifyJSFile(output, entry.file);
72 }
73 break;
74
75 default:
76 //TODO with options compress saved to avoid double compression
77 output = bundler.wrapCode(output, entry, opts);
78 if (opts.compress && entry.file.indexOf('.min') === -1) {
79 output = ss.bundler.minifyJSFile(output, entry.file);
80 }
81 return cb(output);
82 }
83 },
84 function(err) {
85 ss.log.clientIssue(client,options,err,entry);
86 switch(entry.ext) {
87 case 'html':
88 return cb('Couldn\'t format ' + entry.file + err.userInfoHTML);
89 case 'css':
90 return cb('/* couldn\'t format ' + entry.file + err.userInfoText+' */');
91 default:
92 return cb('// couldn\'t format ' + entry.file + err.userInfoText);
93 }
94 });
95 }
96};

Callers

nothing calls this directly

Calls 1

cbFunction · 0.50

Tested by

no test coverage detected