Blame view

node_modules/commoner/bin/commonize 717 Bytes
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #!/usr/bin/env node
  
  require("commoner").resolve(function(id) {
      var context = this;
  
      return context.getProvidedP().then(function(idToPath) {
          // If a module declares its own identifier using @providesModule
          // then that identifier will be a key in the idToPath object.
          if (idToPath.hasOwnProperty(id))
              return context.readFileP(idToPath[id]);
      });
  
  }, function(id) {
      // Otherwise assume the identifier maps directly to a filesystem path.
      return this.readModuleP(id);
  
  }).process(function(id, source) {
      // As a simple example of a processing step, make sure the file ends
      // with exactly one newline character.
      return source.replace(/\s+$/m, "\n");
  });