I'm trying to create a new file template, and it's not working for some reason. I can run the script in a regular shell and it works perfectly, but not within TM.
The script is:
if [[ ! -f "$TM_NEW_FILE" ]]; then TM_YEAR=`date +%Y` \ TM_DATE=`date +%Y-%m-%d` \ TM_CLASS_NAME=`echo "$TM_NEW_FILE_BASENAME" | perl -pe 'm/ ^(unitTest|test)/ && s/(unitTest|test)([[:alnum:]_]*)/$2/'` \ perl -pe 's/${([^}]*)}/$ENV{$1}/g' \ < template_in.txt > "$TM_NEW_FILE" fi
with extension set to "php"
The tempate_in.txt file is:
<?php /** * ${TM_NEW_FILE_BASENAME} * simpletest unit test template: http://www.simpletest.org/ * * Created by ${TM_FULLNAME} on ${TM_DATE}. * Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights reserved. * * @author ${TM_FULLNAME} * @version ${TM_DATE} * @package undefined */
require_once('simpletest/autorun.php');
include '../class.${TM_CLASS_NAME}.php';
class Test${TM_CLASS_NAME} extends UnitTestCase { private static $testlog = 'testlog.log'; function setUp() { error_log(PHP_EOL.'================== %<=========================='.'Test${TM_CLASS_NAME} start '.date("Y/m/ d.H:i:s").PHP_EOL,3,self::$testlog); } function test1() { } }
?>
When I run it in a normal shell with the command:
rm unitTestDebug.php ; TM_NEW_FILE=$PWD/unitTestDebug.php TM_NEW_FILE_BASENAME=unitTestDebug TM_ORGANIZATION_NAME='Miishka' TM_FULLNAME='Tamara Temple' sh -vx new.sh
I get a file in the current directory as unitTestDebug.php containing:
<?php /** * unitTestDebug * simpletest unit test template: http://www.simpletest.org/ * * Created by Tamara Temple on 2011-06-23. * Copyright (c) 2011 Miishka. All rights reserved. * * @author Tamara Temple * @version 2011-06-23 * @package undefined */
require_once('simpletest/autorun.php');
include '../class.Debug.php';
class TestDebug extends UnitTestCase { private static $testlog = 'testlog.log'; function setUp() { error_log(PHP_EOL.'================== %<=========================='.'TestDebug start '.date("Y/m/ d.H:i:s").PHP_EOL,3,self::$testlog); } function test1() { } }
?>
which is exactly what I would expect. If I call up the template in TM drawer's new file creation dialog, I get nothing.
so I'm stumped.
Any help?