Ejemplo n.º 1
0
  files: function() {
    if (this._files) { return this._files; }

    var filesPath = this.filesPath(this.options);
    if (existsSync(filesPath)) {
      this._files = walkSync(filesPath);
    } else {
      this._files = [];
    }

    return this._files;
  },
Ejemplo n.º 2
0
  files() {
    if (this._files) { return this._files; }

    let filesPath = this.filesPath();

    if (fileExists(filesPath)) {
      this._files = walkSync(filesPath);
    } else {
      this._files = [];
    }
    return this._files;
  }
Ejemplo n.º 3
0
  function init (roots) {
    var partials  = { root: roots.partials, paths: walk_sync(roots.partials) };
    var templates = { root: roots.templates, paths: walk_sync(roots.templates) };

    var process_file = process_file_setup({
      compile:            compile,
      read_header:        _.compose(parse.header, read_file),
      find_closest_match: find_closest_match,
      options: {
        env:       env,
        partials:  partials,
        templates: templates
      }
    });

    return run;

    function run (path) {
      return process_file(path).toString();
    }
  }
Ejemplo n.º 4
0
Blueprint.prototype.files = function() {
  if (this._files) { return this._files; }

  var filesPath = path.join(this.path, 'files');
  if (fs.existsSync(filesPath)) {
    this._files = walkSync(path.join(this.path, 'files'));
  } else {
    this._files = [];
  }

  return this._files;
};
Ejemplo n.º 5
0
function assertTmpEmpty() {
  if (!fs.existsSync('tmp')) {
    return;
  }

  var paths = walkSync('tmp')
    .filter(function(path) {
      return !path.match(/output\//);
    });

  assert(paths.length === 0, 'tmp/ should be empty after `ember` tasks. Contained: ' + paths.join(EOL));
}
Ejemplo n.º 6
0
Addon.prototype.shouldCompileTemplates = function() {
  var templateExtensions = this.registry.extensionsForType('template');
  var addonTreePath = path.join(this.root, this.treePaths['addon']);
  var addonTemplatesTreePath = path.join(this.root, this.treePaths['addon-templates']);

  var files = [];

  if (existsSync(addonTreePath)) {
    files = files.concat(walkSync(addonTreePath));
  }

  if (existsSync(addonTemplatesTreePath)) {
    files = files.concat(walkSync(addonTemplatesTreePath));
  }

  var extensionMatcher = new RegExp('(' + templateExtensions.join('|') + ')$');

  return files.some(function(file) {
    return file.match(extensionMatcher);
  });
};
Ejemplo n.º 7
0
Blueprint.prototype.files = function() {
  if (this._files) { return this._files; }

  var filesPath = this.filesPath(this.options);
  if (existsSync(filesPath)) {
    this._files = walkSync(filesPath);
  } else {
    this._files = [];
  }

  return this._files;
};
Ejemplo n.º 8
0
 return assemble(fixturePath('project-simple')).then(({ directory }) => {
   let files = walkSync(directory, { directories: false });
   expect(files).to.deep.equal([
     '.compilerc',
     'ember-electron/electron-forge-config.js',
     'ember-electron/main.js',
     'ember/assets/app.css',
     'ember/assets/app.js',
     'ember/index.html',
     'package.json',
   ]);
 });
Ejemplo n.º 9
0
        .then(function() {
          var actualFiles = walkSync(tmpdir).sort();
          var output = ui.output.trim().split(EOL);

          assert.match(output.shift(), /^installing/);
          assert.match(output.shift(), /identical.* \.ember-cli/);
          assert.match(output.shift(), /identical.* \.gitignore/);
          assert.match(output.shift(), /identical.* foo.txt/);
          assert.match(output.shift(), /identical.* test.txt/);
          assert.equal(output.length, 0);

          assert.deepEqual(actualFiles, basicBlueprintFiles);
        });
Ejemplo n.º 10
0
        .then(function() {
          var actualFiles = walkSync('.').sort();
          var output = ui.output.trim().split('\n');

          assert.match(output.shift(), /^installing/);
          assert.match(output.shift(), /create.* .ember-cli/);
          assert.match(output.shift(), /create.* .gitignore/);
          assert.match(output.shift(), /create.* foo.txt/);
          assert.match(output.shift(), /create.* test.txt/);
          assert.equal(output.length, 0);

          assert.deepEqual(actualFiles, basicBlueprintFiles);
        });
 return build.build().then(function(results) {
   var files = walkSync(results.directory);
   var expectactions = [
     'ember-cli-ember-tests/',
     'ember-cli-ember-tests/dep-graph.json',
     'ember-cli-ember-tests/unit/',
     'ember-cli-ember-tests/ember-test.js'
   ];
   expect(builder.env).to.eql('development');
   expectactions.forEach(function(file) {
     expect(files.indexOf(file) > -1).to.eql(false);
   });
 });
Ejemplo n.º 12
0
  files: function() {
    if (this._files) { return this._files; }

    this._appBlueprint   = this.lookupBlueprint('app');
    var appFiles       = this._appBlueprint.files();

    this.generatePackageJson();
    this.generateBowerJson();

    var addonFiles   = walkSync(path.join(this.path, 'files'));

    return this._files = uniq(appFiles.concat(addonFiles));
  },
Ejemplo n.º 13
0
          .then(function() {
            var actualFiles = walkSync(tmpdir).sort();
            var output = ui.output.trim().split('\n');
            assert.match(output.shift(), /^installing/);
            assert.match(output.shift(), /Overwrite.*test.*\?/); // Prompt
            assert.match(output.shift(), /Overwrite.*test.*No, skip/);
            assert.match(output.shift(), /identical.* \.ember-cli/);
            assert.match(output.shift(), /identical.* \.gitignore/);
            assert.match(output.shift(), /skip.* test.txt/);
            assert.equal(output.length, 0);

            assert.deepEqual(actualFiles, basicBlueprintFiles);
          });
Ejemplo n.º 14
0
        .then(function(results) {
          var outputPath = results.directory;

          var expected = [
            'subdir1/',
            'subdir1/subsubdir1/',
            'subdir1/subsubdir1/foo.png',
            'subdir2/',
            'subdir2/bar.css'
          ];

          expect(walkSync(outputPath)).to.eql(expected);
        });
Ejemplo n.º 15
0
        .then(function() {
          var actualFiles = walkSync(tmpdir).sort();
          var output = ui.output.trim().split(EOL);

          expect(output.shift()).to.match(/^installing/);
          expect(output.shift()).to.match(/identical.* .ember-cli/);
          expect(output.shift()).to.match(/identical.* .gitignore/);
          expect(output.shift()).to.match(/identical.* bar/);
          expect(output.shift()).to.match(/identical.* foo.txt/);
          expect(output.shift()).to.match(/identical.* test.txt/);
          expect(output.length).to.equal(0);

          expect(actualFiles).to.deep.equal(basicBlueprintFiles);
        });
Ejemplo n.º 16
0
  _getIncludesForDir: function(dir, prefix) {
    if (fs.existsSync(dir)) {
      let dirname = path.relative(this.project.root, dir);
      let globs = this.parentRegistry.extensionsForType('js').map((extension) => `**/*.${extension}`);

      return walkSync(dir, { directories: false, globs }).map(file => {
        let module = prefix + '/' + file.replace(EXT_RE, '.js');
        this.fileLookup[module] = path.join(dirname, file);
        return module;
      });
    } else {
      return [];
    }
  },
Ejemplo n.º 17
0
      .then(function(result) {
        var outputPath = result.directory;

        var files = walkSync(outputPath)
          .filter(function(file) {
            return /jscs-test.js$/.test(file);
          });

        files.forEach(function(file) {
          var contents = fs.readFileSync(path.join(outputPath, file), { encoding: 'utf8' });

          callback(contents);
        });
      });
 return build.build().then(function(results) {
   var files = walkSync(results.directory);
   var expectactions = [
     'dummy/tests/',
     'dummy/tests/dep-graph.json',
     'dummy/tests/unit/',
     'dummy/tests/unit/components/',
     'dummy/tests/unit/components/foo-bar-test.js'
   ];
   expect(builder.env).to.eql('development');
   expectactions.forEach(function(file) {
     expect(files.indexOf(file) > -1).to.eql(true);
   });
 });
Ejemplo n.º 19
0
        .then(function() {

          let actualFiles = walkSync(tmpdir).sort();
          // Prompts contain \n EOL
          // Split output on \n since it will have the same affect as spliting on OS specific EOL
          let output = ui.output.trim().split('\n');
          expect(output.shift()).to.match(/^installing/);
          expect(output.shift()).to.match(/identical.* \.ember-cli/);
          expect(output.shift()).to.match(/identical.* \.gitignore/);
          expect(output.shift()).to.match(/skip.* test.txt/);
          expect(output.length).to.equal(0);

          expect(actualFiles).to.deep.equal(basicBlueprintFiles);
        });
Ejemplo n.º 20
0
        .then(function(results) {
          var outputPath = results.directory;

          var expected = [
            'subdir1/',
            'subdir1/subsubdir1/',
            'subdir1/subsubdir1/foo.png',
          ];

          expect(walkSync(outputPath)).to.eql(expected);

          // Build again
          return builder.build();
        })
Ejemplo n.º 21
0
  return mapSeries(this.inputTrees, readTree).then(function (treePaths) {
    for (var i = treePaths.length - 1; i >= 0; i--) {
      var treeContents = walkSync(treePaths[i])
      treeContents = treeContents.map(toLowerCase)

      var fileIndex
      for (var j = 0; j < treeContents.length; j++) {
        var relativePath = treeContents[j]
        var destPath = destDir + '/' + relativePath
        if (relativePath.slice(-1) === '/') { // is directory
          relativePath = relativePath.slice(0, -1) // chomp "/"
          fileIndex = files[relativePath]
          if (fileIndex != null) {
            throwFileAndDirectoryCollision(relativePath, fileIndex, i)
          }
          if (directories[relativePath] == null) {
            fs.mkdirSync(destPath)
            directories[relativePath] = i
          }
        } else { // is file
          var directoryIndex = directories[relativePath]
          if (directoryIndex != null) {
            throwFileAndDirectoryCollision(relativePath, i, directoryIndex)
          }
          fileIndex = files[relativePath]
          if (fileIndex != null) {
            if (!self.options.overwrite) {
              throw new Error('Merge error: ' +
                'file "' + relativePath + '" exists in ' +
                treePaths[i] + ' and ' + treePaths[fileIndex] + ' - ' +
                'pass option { overwrite: true } to mergeTrees in order ' +
                'to have the latter file win')
            }
            // Else, ignore this file. It is "overwritten" by a file we copied
            // earlier, thanks to reverse iteration over trees
          } else {
            helpers.copyPreserveSync(
              treePaths[i] + '/' + relativePath, destPath)
            files[relativePath] = i
          }
        }
      }
    }

    function throwFileAndDirectoryCollision (relativePath, fileIndex, directoryIndex) {
      throw new Error('Merge error: "' + relativePath +
        '" exists as a file in ' + treePaths[fileIndex] +
        ' but as a directory in ' + treePaths[directoryIndex])
    }
  })
Ejemplo n.º 22
0
  function confirmBlueprinted() {
    var blueprintPath = path.join(root, 'addon', 'ng2', 'blueprints', 'ng2', 'files');
    var expected = walkSync(blueprintPath).sort();
    var actual = walkSync('.').sort();

    forEach(Blueprint.renamedFiles, function (destFile, srcFile) {
      expected[expected.indexOf(srcFile)] = destFile;
    });

    expected.forEach(function (file, index) {
      expected[index] = file.replace(/__name__/g, 'tmp');
      expected[index] = expected[index].replace(/__styleext__/g, 'css');
    });

    removeIgnored(expected);
    removeIgnored(actual);

    expected.sort();

    expect(expected).to.deep.equal(
      actual,
      EOL + ' expected: ' + util.inspect(expected) + EOL + ' but got: ' + util.inspect(actual));
  }
Ejemplo n.º 23
0
    return new RSVP.Promise(function(resolve) {
      var files = walkSync(projectRoot, {
        globs: ['**/.jshintrc'],
        ignore: [
          '**/bower_components',
          '**/dist',
          '**/node_modules',
          '**/tmp'
        ]
      });

      ui.stopProgress();
      resolve(files);
    });
Ejemplo n.º 24
0
          .then(function() {
            var actualFiles = walkSync(tmpdir).sort();
            // Prompts contain \n EOL
            // Split output on \n since it will have the same affect as spliting on OS specific EOL
            var output = ui.output.trim().split('\n');
            assert.match(output.shift(), /^installing/);
            assert.match(output.shift(), /Overwrite.*test.*\?/); // Prompt
            assert.match(output.shift(), /Overwrite.*test.*No, skip/);
            assert.match(output.shift(), /identical.* \.ember-cli/);
            assert.match(output.shift(), /identical.* \.gitignore/);
            assert.match(output.shift(), /skip.* test.txt/);
            assert.equal(output.length, 0);

            assert.deepEqual(actualFiles, basicBlueprintFiles);
          });
Ejemplo n.º 25
0
  _updateEachFile: function(inDir, outDir){
    // this object is passed through the caching process
    // and populated with newly generated or previously cached
    // values. It becomes the new cache;
    var _newTranspilerCache = {};

    walkSync(inDir)
      .forEach(function(relativePath) {
        if (this._shouldProcessFile(relativePath)) {
          this._handleFile(inDir, outDir, relativePath, _newTranspilerCache);
        }
      }, this);

    this._transpilerCache = _newTranspilerCache;
  },
Ejemplo n.º 26
0
 return readTree(this.inputTrees[0]).then(function(srcDir){
   var paths = walkSync(srcDir);
   var stubs = {};
   var updateCacheResult;
   paths.forEach(function (relativePath) {
     if (relativePath.slice(-3) === '.js') {
       gatherStubs(srcDir, relativePath, stubs, self.importsCache);
     }
   });
   if (!sameStubs(stubs, self.stubsCache)) {
     self.stubsCache = stubs;
     updateCacheResult = self.updateCache(srcDir, self.getCleanCacheDir());
   }
   return updateCacheResult;
 }).then(function(){
Ejemplo n.º 27
0
  return readTree(this.inputTree).then(function (srcDir) {
    var paths = walkSync(srcDir)

    return mapSeries(paths, function (relativePath) {
      if (relativePath.slice(-1) === '/') {
        mkdirp.sync(destDir + '/' + relativePath)
      } else {
        if (self.canProcessFile(relativePath)) {
          return self.processAndCacheFile(srcDir, destDir, relativePath)
        } else {
          helpers.copyPreserveSync(
            srcDir + '/' + relativePath, destDir + '/' + relativePath)
        }
      }
    })
  })
Ejemplo n.º 28
0
const run = async () => {
    const configPath = path.join(__dirname, '../config');
    const files = walkSync(configPath);
    const isolateFile = files.find(name => name.startsWith('isolate-'));
    if (!isolateFile) throw new Error('no isolate-* file found');
    const isolatePath = configPath + '/' + isolateFile;
    const cmd = 'node --prof-process ' + isolatePath + ' > processed.txt';
    if (shell.exec(cmd).code !== 0) {
        console.error('processing ' + isolatePath + ' failed');
        process.exit(1);
    }

    await del.promise([isolatePath]);

    console.log('DONE - open processed.txt');
};
Ejemplo n.º 29
0
  findFiles() {
    let outputPath = this.outputPath;

    try {
      return walkSync(outputPath, {
        directories: false,
      }).filter(x => x.endsWith('.css') || x.endsWith('.js'))
        .map(x => `${outputPath}/${x}`);
    } catch (e) {
      if (e !== null && typeof e === 'object' && e.code === 'ENOENT') {
        throw new Error(`No asset files found in the path provided: ${outputPath}`);
      } else {
        throw e;
      }
    }
  }
Ejemplo n.º 30
0
        .then(function() {
          var actualFiles = walkSync(tmpdir).sort();
          var globFiles = glob.sync(path.join('**', 'foo.txt'), {
              cwd: tmpdir,
              dot: true,
              mark: true,
              strict: true
            }).sort();
          var output = ui.output.trim().split(EOL);

          expect(output.shift()).to.match(/^installing/);
          expect(output.shift()).to.match(/create.* foo.txt/);
          expect(output.length).to.equal(0);

          expect(actualFiles).to.deep.equal(globFiles);
        });