add injectable staticPaths to opts.injectCss or opts.injectJs
482111
function injectPaths(paths) {
    u.each(paths, function(path) {
      if (path.inject) {
        // injected css and js sources are always rooted paths
        var src = mkSrc(path);
        if (/\.css$/i.test(src.path)) return opts.injectCss.push(src);
        if (/\.js$|\.es6$|\.jsx$/i.test(src.path)) return opts.injectJs.push(src);
        return opts.log('Don\'t know how to inject', path.path);
      }
    });
  }
825461
def create_templates_static_files(app_path):
    
    templates_path = os.path.join(app_path, 'templates')
    static_path = os.path.join(app_path, 'static')
    _mkdir_p(templates_path)
    _mkdir_p(static_path)
    # create {img, css, js}
    os.chdir(static_path)
    img_path = os.path.join(static_path, 'img')
    css_path = os.path.join(static_path, 'css')
    js_path = os.path.join(static_path, 'js')
    _mkdir_p(img_path)
    _mkdir_p(css_path)
    _mkdir_p(js_path)

    return css_path, templates_path
1293618
function (abspath, targetFilePath, pattern, files, staticBlock) {
        if (targetFilePath in files) {
            grunt.warn('In the file: ' + abspath + ', the target filename: ' + targetFilePath + ' has already defined in this or other html template file.');
        }
        var results = staticBlock.match(pattern);
        if (results) {
            files[targetFilePath] = [];
            for (var index in results) {
                // results[index] could be like below, use staticPattern to fetch real static filepath further.
                // <link href="${request.static_url('zuoyeproject:static/css/bootstrap.css')}" rel="stylesheet" media="screen">
                // <script src="${request.static_url('zuoyeproject:static/editor/common.js')}">
                var result = results[index].match(applyminGlobal.staticPattern);
                if (result === null || result.length < 2) {
                    grunt.warn('Please check whether your "options.staticPattern": ' + applyminGlobal.staticPattern + '\n\ncould be used to fetch the static resource:\n\n' + results[index] + '\n\nin the file ' + '"' + abspath + '"');
                }
                if (!grunt.file.exists(result[1])) {
                    grunt.warn('This file does not exist: "' + result[1] + '"');
                }
                files[targetFilePath].push(result[1]);
            }
        }
    }
443605
function compileLess(lessPaths, cb) {

        if (lessPaths.length > 0) {

            var path = pathModule.join(base, lessPaths.shift());
            var content = fs.readFileSync(path, 'utf8');

            less.render(
              content,

            function(err, result) {
                if (err) {
                    cb(FOUND_ERROR, 'Error while compiling less template "' + path + '". Error from "less" plugin: ' + err);
                }

                if (options.autoprefixer) {
                  // Call autoprefixer on current built css
                  postcss([ autoprefixer(options.autoprefixer) ])
                    .process(result.css)
                    .then(function(prefixedResult) {
                      // escape any backticks that comeup in the compiled css
                      cb(FOUND_SUCCESS, prefixedResult.css.toString().replace(/\\([\s\S])|(`)/g,"\\$1$2"), lessPaths);
                    });
                } else {
                  // escape any backticks that comeup in the compiled css
                  cb(FOUND_SUCCESS, result.css.toString().replace(/\\([\s\S])|(`)/g,"\\$1$2"), lessPaths);
                }
            });
        }
        else {
            cb(CODE_EXIT);
        }
    }
1333831
function requireJSPath(file, extension) {
	return path.join(path.dirname(file), path.basename(file, extension)).replace(/\\/g, '/');
}
554075
function addStaticRoute(routePath, targets) {
		if (!Object.isArray(targets)) {
			targets = [targets];
		}
		targets.forEach(function(target) {
			if (target)
				app.use(routePath, app.middleware.static(path.resolve(config.rootDir, target)));
		});
	}
1181878
function injectDependencies(globalConfig) {
  config = globalConfig;
  var stream = config.get('stream');

  globalDependenciesSorted = config.get('global-dependencies-sorted');
  ignorePath = config.get('ignore-path');
  fileTypes = config.get('file-types');

  if (stream.src) {
    config.set('stream', {
      src: injectScriptsStream(stream.path, stream.src, stream.fileType),
      fileType: stream.fileType
    });
  } else {
    config.get('src').forEach(injectScripts);
  }

  return config;
}
1166455
function getStatic(id, basedir, config, name, lesspaths, done) {
  if (arguments.length === 5) {
    done = lesspaths;
    lesspaths = name;
    name = 'config';
  }
  async.parallel({
    html: function (next) {
      var failhard = !!config.template;
      if (config.template && !config.template.match(/\.html$/)) return next(null, config.template);
      fs.readFile(path.join(basedir, config.template || 'config/' + name + '.html'), 'utf8', function (err, data) {
        next(failhard && err, data);
      });
    },
    js: function (next) {
      var failhard = !!config.script;
      fs.readFile(path.join(basedir, config.script || 'config/' + name + '.js'), 'utf8', function (err, text) {
        if (!failhard && err) return next(null, '');
        next(err, text + '\n//# sourceUrl=' + id + '/' + path.join(basedir, config.script || 'config/' + name + '.js') + '\n');
      });
    },
    css: function (next) {
      var failhard = !!config.style;
      fs.readFile(path.join(basedir, config.style || 'config/' + name + '.less'), 'utf8', function (err, text) {
        if (!failhard && err) return next(null, '');
        var source = '\n/** source: ' + id + '/' + (config.style || 'config/' + name + '.less') + ' **/\n';
        if (err) return next(err);
        if (config.style && config.style.slice(-5) !== '.less') {
          return next(null, text + source);
        }
        var fpath = path.join(basedir, config.style || name + '.less');
        
        less.render(text, {
          paths: [path.dirname(fpath)].concat(lesspaths || []),
          filename: fpath
        }).then(function(output) {
          next(null, output.css + source);
        }, function(error) {
          next(error);
        });
      });
    }
  }, function (err, data) {
    return done(err, data.html, data.css, data.js);
  });
}
1085822
function resolveConfig({
    filePath,
    stylelintPath,
    stylelintConfig,
    prettierOptions
}) {
    const resolve = resolveConfig.resolve;
    const stylelint = requireRelative(stylelintPath, filePath, 'stylelint');
    const linterAPI = stylelint.createLinter();

    if (stylelintConfig) {
        return Promise.resolve(resolve(stylelintConfig, prettierOptions));
    }

    return linterAPI
        .getConfigForFile(filePath)
        .then(({ config }) => resolve(config, prettierOptions));
}
373137
function injectSiteAsync(content) {
        function genSiteAsyncMap() {
            var asyncList = [];
            fis.util.map(ret.map.res, function (id) {
                var res = ret.ids[id];
                if (res.isJsLike) {
                    asyncList.push(ret.ids[id]);
                }
            });
            var subpath = (settings.subpath || 'pkg/map.js').replace(/^\//, '');
            return genAsyncMap(asyncList, subpath, null, settings.codeGen);
        }

        if (!siteAsync)
            siteAsync = genSiteAsyncMap();
        return injectAsyncWithMap(content, siteAsync);
    }
746676
function(filePath, baseURL, System) {
      // Convert file paths to module name by stripping the baseURL and the ".js" extension
      if (System.defaultJSExtensions) {
        filePath = filePath.replace(/\.js$/, '');
      }
      return filePath
        .replace(new RegExp('^' + baseURL.replace('/', '\/')), '');
    }
565667
function injectParams(pattern, params) {
    params = params || {};

    var splatIndex = 0;

    return pattern.replace(paramInjectMatcher, function (match, paramName) {
      paramName = paramName || 'splat';

      // If param is optional don't check for existence
      if (paramName.slice(-1) === '?') {
        paramName = paramName.slice(0, -1);

        if (params[paramName] == null) return '';
      } else {
        invariant(params[paramName] != null, 'Missing "%s" parameter for path "%s"', paramName, pattern);
      }

      var segment;
      if (paramName === 'splat' && Array.isArray(params[paramName])) {
        segment = params[paramName][splatIndex++];

        invariant(segment != null, 'Missing splat # %s for path "%s"', splatIndex, pattern);
      } else {
        segment = params[paramName];
      }

      return segment;
    }).replace(paramInjectTrailingSlashMatcher, '/');
  }
685253
function(paths) {

      function relativePath(p, dirType) {
          var relativeStart = p.indexOf('./') === 0 || p.indexOf('../') === 0;
          return relativeStart? prefixPath(options.dirs.client,p) : prefixPath(options.dirs[dirType], p);
      }

      function prefixPath(base,p) {
          base = base.replace(/^\//,'');
          if (p === '*') {
            return base;
          }
          p = p.replace(/\/\*$/,'');
          return path.join(base,p);
      }

      function entries(from, dirType) {
        if (from == null) {
          return [];
        }
        var list = (from instanceof Array)? from : [from];

        return list.map(function(value) {
          return relativePath(value, dirType);
        });
      }

      paths.css = entries(paths.css, 'css');
      paths.code = entries(paths.code, 'code');
      paths.tmpl = entries(paths.tmpl || paths.templates, 'templates');

      if (paths.view) {
        paths.view = relativePath(paths.view, 'views');
      }

      return paths;
    }
850262
def set_statics(self):
        
        if not os.path.exists(self.results_dir):
            return None
        try:
            shutil.copytree(os.path.join(self.templates_dir, 'css'), os.path.join(self.results_dir, 'css'))
            shutil.copytree(os.path.join(self.templates_dir, 'scripts'), os.path.join(self.results_dir, 'scripts'))
            shutil.copytree(os.path.join(self.templates_dir, 'fonts'), os.path.join(self.results_dir, 'fonts'))
        except OSError as e:
            if e.errno == 17:  # File exists
                print("WARNING : existing output directory for static files, will not replace them")
            else:  # in all other cases, re-raise exceptions
                raise
        try:
            shutil.copytree(os.path.join(self.templates_dir, 'img'), os.path.join(self.results_dir, 'img'))
        except OSError as e:
            pass
1151492
function injectTemplate(forModule) {
  return (
    gulp
      .src(
        forModule
          ? `./${config.temp.path}/${config.element.tag}.js`
          : `./${config.temp.path}/${config.element.tag}.script.js`
      )

      // Inject the template html.
      .pipe(
        inject(gulp.src(`./${config.temp.path}/${config.src.template.html}`), {
          starttag: '[[inject:template]]',
          endtag: '[[endinject]]',
          removeTags: true,
          transform: util.transforms.getFileContents
        })
      )

      // Inject the style css.
      .pipe(
        inject(gulp.src(`./${config.temp.path}/${config.src.template.css}`), {
          starttag: '[[inject:style]]',
          endtag: '[[endinject]]',
          removeTags: true,
          transform: util.transforms.getFileContents
        })
      )
      .pipe(gulp.dest(`./${config.temp.path}`))
  );
}
250022
def _create_jspath(self) -> Path:
        """"""
        src = self._build_dir / 'bowtiejs'
        os.makedirs(src, exist_ok=True)
        return src
663627
function addStaticAssetRoute(server, scaffold) {
        assert(scaffold.path, `TransomScaffold staticRoute requires "path" to be specified.`);

        const contentFolder = scaffold.folder || path.sep;
        const serveStatic = scaffold.serveStatic || restify.plugins.serveStatic;
        const defaultAsset = scaffold.defaultAsset || 'index.html';
        const appendRequestPath = (scaffold.appendRequestPath  === false ? false : true); // default true

        // When we are running tests, the path to our assets will be different. 
        // We create the path using NODE_ENV which should be set to TESTING.
        let directory = path.join(__dirname, '..', '..', '..', '..', contentFolder);
        if ((process.env.NODE_ENV || '').toUpperCase() === 'TESTING') {
            directory = path.join(__dirname, "..", contentFolder);
        }
        debug(`Path ${scaffold.path} is serving static assets from ${directory}`);

        server.get(scaffold.path, serveStatic({
            directory,
            appendRequestPath,
            default: defaultAsset
        }));
    }